[rrd-developers] [PATCH] Do not trust cache tree pointers after releasing the cache lock.

kevin brintnall kbrint at rufus.net
Sun Jul 12 00:46:04 CEST 2009


It's possible that a "FORGET" was issued in the mean time.
---
 src/rrd_daemon.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
index d8f140e..17ec97e 100644
--- a/src/rrd_daemon.c
+++ b/src/rrd_daemon.c
@@ -913,7 +913,14 @@ static void *queue_thread_main (void *args __attribute__((unused))) /* {{{ */
     }
 
     journal_write("wrote", file);
-    pthread_cond_broadcast(&ci->flushed);
+
+    /* Search again in the tree.  It's possible someone issued a "FORGET"
+     * while we were writing the update values. */
+    pthread_mutex_lock(&cache_lock);
+    ci = (cache_item_t *) g_tree_lookup(cache_tree, file);
+    if (ci)
+      pthread_cond_broadcast(&ci->flushed);
+    pthread_mutex_unlock(&cache_lock);
 
     rrd_free_ptrs((void ***) &values, &values_num);
     free(file);
-- 
1.6.3.1



More information about the rrd-developers mailing list