Code

Merge branch 'collectd-4.1'
[collectd.git] / src / rrdtool.c
index 9fc687285cab7ae9894f3285d086a5f810d52b7f..e356bf19d6d91fb4a275fffb840df0c6f3827a4b 100644 (file)
@@ -24,6 +24,8 @@
 #include "common.h"
 #include "utils_avltree.h"
 
+#include <rrd.h>
+
 #if HAVE_PTHREAD_H
 # include <pthread.h>
 #endif
@@ -652,6 +654,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++)
                {
@@ -1051,6 +1055,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)
        {
@@ -1059,11 +1068,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 */