[rrd-developers] [PATCH] [BUG] fixed hang in flush_file() introduced by per-file flush condition

kevin brintnall kbrint at rufus.net
Fri Sep 26 21:57:09 CEST 2008


A RRD file with no values would not be enqueued, so it would never be
flushed.  Therefore, its "flushed" condition would never be broadcast.
Therefore, a "flush" issued against a file with no updates would block
until the file was written to disk for another reason (i.e. periodic
timer, flush after update, etc).

If we have no values, do not try to enqueue the RRD, and do not block
waiting for it to be flushed.
---
 src/rrd_daemon.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
index d6f77eb..36d090c 100644
--- a/src/rrd_daemon.c
+++ b/src/rrd_daemon.c
@@ -745,12 +745,14 @@ static int flush_file (const char *filename) /* {{{ */
     return (ENOENT);
   }
 
-  /* Enqueue at head */
-  enqueue_cache_item (ci, HEAD);
-  pthread_cond_signal (&cache_cond);
+  if (ci->values > 0)
+  {
+    /* Enqueue at head */
+    enqueue_cache_item (ci, HEAD);
+    pthread_cond_signal (&cache_cond);
+    pthread_cond_wait(&ci->flushed, &cache_lock);
+  }
 
-  pthread_cond_wait(&ci->flushed, &cache_lock);
-  assert((ci->flags & CI_FLAGS_IN_QUEUE) == 0);
   pthread_mutex_unlock(&cache_lock);
 
   return (0);
-- 
1.6.0.2



More information about the rrd-developers mailing list