X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrdtool.c;h=d274ba021b65146cd2cf7195421e045c52a1f5d5;hb=b400d28e853eea66d6f233a3524009dea01d9e41;hp=7002dcfbd61050616d9e308def88ff48b67895f3;hpb=5e73df5f8ec52055e5f79be5d898e5baec4c9967;p=collectd.git diff --git a/src/rrdtool.c b/src/rrdtool.c index 7002dcfb..d274ba02 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -24,6 +24,8 @@ #include "common.h" #include "utils_avltree.h" +#include + #if HAVE_PTHREAD_H # include #endif @@ -714,7 +716,7 @@ static void rrd_cache_flush (int timeout) avl_iterator_t *iter; int i; - DEBUG ("Flushing cache, timeout = %i", timeout); + DEBUG ("rrdtool plugin: Flushing cache, timeout = %i", timeout); now = time (NULL); @@ -722,8 +724,6 @@ static void rrd_cache_flush (int timeout) iter = avl_get_iterator (cache); while (avl_iterator_next (iter, (void *) &key, (void *) &rc) == 0) { - DEBUG ("key = %s; age = %i;", key, now - rc->first_value); - if (rc->flags == FLAG_QUEUED) continue; else if ((now - rc->first_value) < timeout) @@ -757,7 +757,7 @@ static void rrd_cache_flush (int timeout) { if (avl_remove (cache, keys[i], (void *) &key, (void *) &rc) != 0) { - DEBUG ("avl_remove (%s) failed.", keys[i]); + DEBUG ("rrdtool plugin: avl_remove (%s) failed.", keys[i]); continue; } @@ -770,7 +770,6 @@ static void rrd_cache_flush (int timeout) } /* for (i = 0..keys_num) */ free (keys); - DEBUG ("Flushed %i value(s)", keys_num); cache_flush_last = now; } /* void rrd_cache_flush */ @@ -860,8 +859,10 @@ static int rrd_cache_insert (const char *filename, avl_insert (cache, cache_key, rc); } - DEBUG ("rrd_cache_insert (%s, %s, %u) = %p", filename, value, - (unsigned int) value_time, (void *) rc); + DEBUG ("rrdtool plugin: rrd_cache_insert: file = %s; " + "values_num = %i; age = %u;", + filename, rc->values_num, + rc->last_value - rc->first_value); if ((rc->last_value - rc->first_value) >= cache_timeout) { @@ -1052,6 +1053,11 @@ static int rrd_shutdown (void) rrd_cache_flush (-1); pthread_mutex_unlock (&cache_lock); + pthread_mutex_lock (&queue_lock); + do_shutdown = 1; + pthread_cond_signal (&queue_cond); + pthread_mutex_unlock (&queue_lock); + /* Wait for all the values to be written to disk before returning. */ if (queue_thread != 0) { @@ -1060,11 +1066,6 @@ static int rrd_shutdown (void) DEBUG ("rrdtool plugin: queue_thread exited."); } - pthread_mutex_lock (&queue_lock); - do_shutdown = 1; - pthread_cond_signal (&queue_cond); - pthread_mutex_unlock (&queue_lock); - return (0); } /* int rrd_shutdown */