[collectd] [PATCH] rrdtool plugin: Get the cache lock before checking for a nonexistent cache.

Sebastian Harl sh at tokkee.org
Wed Feb 27 21:56:32 CET 2008


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 at tokkee.org>
---
 src/rrdtool.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/rrdtool.c b/src/rrdtool.c
index 4e34d6a..ab24524 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);
-- 
1.5.4.2.184.gb23b

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080227/0b4fefee/attachment.pgp 


More information about the collectd mailing list