diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-29 18:11:56 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-29 18:11:56 +0300 |
commit | 5a1f674eecba607ffa328484ca34c598690ff8d2 (patch) | |
tree | 5dcda78e8352461d2ee7fdc29c64a265024cb219 /src/report.c | |
parent | 20d7f1d7e051c6b021a3f5d088985a74c3370b29 (diff) | |
download | tagr-5a1f674eecba607ffa328484ca34c598690ff8d2.tar.gz tagr-5a1f674eecba607ffa328484ca34c598690ff8d2.tar.bz2 |
Fix locking issues. Improve stream interface.
* gnulib.modules: Add c-type, c-strcase, crypto/md5,
xgetdomainname, xgethostname.
* src/Makefile.am (tagr_SOURCES): Add apop.c, udb.c, xhostname.c
* src/graph.c (draw_graph): Rename `now' to `start'.
* src/main.c (hostname, rebuild_last_option): New globals.
(main): Init hostname.
* src/output.c (update_output): Change semantics of the last
parameter.
* src/readconfig.c (cb_facility): Use c_strcasecmp.
(tagr_kw): New keywords: hostname, udb-file, lock-count,
lock-timeout, idle-timeout.
* src/report.c: Fix locking issues.
(update_monitor): Change semantics of the last parameter.
(rebuild): Likewise.
* src/server.c: Rewrite stream interface.
* src/tagr.h (TAGR_ARG_UNUSED, TAGR_PRINTFLIKE): New macros.
(lock_retry_count_option, lock_retry_timeout_option)
(stream_idle_timeout, hostname): New declarations.
(TAGR_UPD_FORCE, TAGR_UPD_LASTTIME): New defines.
(trim_crlf, tagr_local_hostnamem tagr_auth_init, tagr_auth)
(tagr_udb_name)
(udb_get_passwordudb_free_password): New declarations.
* TODO: Update
Diffstat (limited to 'src/report.c')
-rw-r--r-- | src/report.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/report.c b/src/report.c index 71a735f..ab4cada 100644 --- a/src/report.c +++ b/src/report.c @@ -35,2 +35,5 @@ +unsigned lock_retry_count_option = 5; +unsigned lock_retry_timeout_option = 1; + static char *dbname; @@ -47,9 +50,16 @@ open_db (int flag) { - dbname = xmalloc (strlen (basedir) + 1 + sizeof (TAGR_DBNAME)); - strcpy (dbname, basedir); - strcat (dbname, "/"); - strcat (dbname, TAGR_DBNAME); - dbf = gdbm_open (dbname, 0, - flag == TAGR_DB_WR ? GDBM_WRCREAT : GDBM_READER, - TAGR_DBMODE, tagr_db_report); + unsigned i; + + dbname = mkfilename (basedir, TAGR_DBNAME, NULL); + + for (i = 0; i < lock_retry_count_option; i++) + { + dbf = gdbm_open (dbname, 0, + flag == TAGR_DB_WR ? GDBM_WRCREAT : GDBM_READER, + TAGR_DBMODE, tagr_db_report); + if (dbf || errno != EAGAIN) + break; + sleep (lock_retry_timeout_option); + } + if (dbf == NULL) @@ -253,3 +263,3 @@ report (Stat *stat, time_t timestamp) int -update_monitor (datum key, time_t timestamp, int force) +update_monitor (datum key, time_t timestamp, int flags) { @@ -275,4 +285,3 @@ update_monitor (datum key, time_t timestamp, int force) { - update_output (mon, tr, tr->last.time /*FIXME: must be now? */, - force); + update_output (mon, tr, timestamp, flags); free (tr); @@ -284,3 +293,3 @@ update_monitor (datum key, time_t timestamp, int force) void -rebuild (int force) +rebuild (int flags) { @@ -289,3 +298,3 @@ rebuild (int force) time_t now = time (NULL); - + verbose (1, _("rebuild initiated")); @@ -296,4 +305,4 @@ rebuild (int force) { - datum nextkey = gdbm_nextkey ( dbf, key ); - update_monitor (key, now, force); + datum nextkey = gdbm_nextkey (dbf, key); + update_monitor (key, now, flags); free (key.dptr); |