From 91ccfb61e4da1094e7a845d0a5982d90cd77e78e Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 27 Feb 2008 21:56:32 +0100 Subject: [PATCH] rrdtool plugin: Get the cache lock before checking for a nonexistent cache. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/rrdtool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); -- 2.11.0