From: Sebastian Harl Date: Wed, 27 Feb 2008 20:56:32 +0000 (+0100) Subject: rrdtool plugin: Get the cache lock before checking for a nonexistent cache. X-Git-Tag: collectd-4.4.0~87^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=91ccfb61e4da1094e7a845d0a5982d90cd77e78e;p=collectd.git rrdtool plugin: Get the cache lock before checking for a nonexistent cache. 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 Signed-off-by: Florian Forster --- diff --git a/src/rrdtool.c b/src/rrdtool.c index 4e34d6ad..ab245241 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -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);