X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Frrdtool.c;h=0dae46b3fe7b4eb5d46e097b16ca5055cb9bbaaf;hb=b67018ceb3e0ca96242e49fb2c644c5ea7215dd7;hp=06d9763968292de2a4ab85ffa3628bd4e72fa3e4;hpb=8f4efb323a686933b94b1e4032ea5429dcac4328;p=collectd.git diff --git a/src/rrdtool.c b/src/rrdtool.c index 06d97639..0dae46b3 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -652,6 +652,8 @@ static void *rrd_queue_thread (void *data) /* Write the values to the RRD-file */ srrd_update (queue_entry->filename, NULL, values_num, values); + DEBUG ("rrdtool plugin: queue thread: Wrote %i values to %s", + values_num, queue_entry->filename); for (i = 0; i < values_num; i++) { @@ -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) { @@ -1057,6 +1058,14 @@ static int rrd_shutdown (void) 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) + { + pthread_join (queue_thread, NULL); + queue_thread = 0; + DEBUG ("rrdtool plugin: queue_thread exited."); + } + return (0); } /* int rrd_shutdown */