rrdtool plugin: Get the cache lock before checking for a nonexistent cache.
authorSebastian Harl <sh@tokkee.org>
Wed, 27 Feb 2008 20:56:32 +0000 (21:56 +0100)
committerFlorian Forster <octo@huhu.verplant.org>
Wed, 27 Feb 2008 21:48:18 +0000 (22:48 +0100)
This should not make any difference, but, in theory, this is a semantical
error, so, let's just fix it :-)

Thanks to Stefan Völkel for pointing this out.

Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/rrdtool.c

index 4e34d6a..ab24524 100644 (file)
@@ -949,10 +949,13 @@ static int rrd_write (const data_set_t *ds, const value_list_t *vl)
 
 static int rrd_flush (const int timeout)
 {
-       if (cache == NULL)
+       pthread_mutex_lock (&cache_lock);
+
+       if (cache == NULL) {
+               pthread_mutex_unlock (&cache_lock);
                return (0);
+       }
 
-       pthread_mutex_lock (&cache_lock);
        rrd_cache_flush (timeout);
        pthread_mutex_unlock (&cache_lock);
        return (0);