summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6852f05)
raw | patch | inline | side by side (parent: 6852f05)
author | Florian Forster <octo@noris.net> | |
Wed, 7 Apr 2010 09:41:41 +0000 (11:41 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 7 Apr 2010 09:41:41 +0000 (11:41 +0200) |
src/rrdtool.c | patch | blob | history |
diff --git a/src/rrdtool.c b/src/rrdtool.c
index ed1ced1f6547ce87ec698f39b9a986545baa5de4..01fca30aad69751bf9a75c6aa39af2ffa568f335 100644 (file)
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
sfree (queue_entry);
} /* while (42) */
- pthread_mutex_lock (&cache_lock);
- c_avl_destroy (cache);
- cache = NULL;
- pthread_mutex_unlock (&cache_lock);
-
pthread_exit ((void *) 0);
return ((void *) 0);
} /* void *rrd_queue_thread */
return (0);
} /* int rrd_cache_insert */
+static int rrd_cache_destroy (void) /* {{{ */
+{
+ void *key = NULL;
+ void *value = NULL;
+
+ int non_empty = 0;
+
+ pthread_mutex_lock (&cache_lock);
+
+ if (cache == NULL)
+ {
+ pthread_mutex_unlock (&cache_lock);
+ return (0);
+ }
+
+ while (c_avl_pick (cache, &key, &value) == 0)
+ {
+ rrd_cache_t *rc;
+ int i;
+
+ sfree (key);
+ key = NULL;
+
+ rc = value;
+ value = NULL;
+
+ if (rc->values_num > 0)
+ non_empty++;
+
+ for (i = 0; i < rc->values_num; i++)
+ sfree (rc->values[i]);
+ sfree (rc->values);
+ sfree (rc);
+ }
+
+ c_avl_destroy (cache);
+ cache = NULL;
+
+ if (non_empty > 0)
+ {
+ INFO ("rrdtool plugin: %i cache %s had values when destroying the cache.",
+ non_empty, (non_empty == 1) ? "entry" : "entries");
+ }
+ else
+ {
+ DEBUG ("rrdtool plugin: No values have been lost "
+ "when destroying the cache.");
+ }
+
+ pthread_mutex_unlock (&cache_lock);
+ return (0);
+} /* }}} int rrd_cache_destroy */
+
static int rrd_compare_numeric (const void *a_ptr, const void *b_ptr)
{
int a = *((int *) a_ptr);
char values[512];
int status;
+ if (do_shutdown)
+ return (0);
+
if (0 != strcmp (ds->type, vl->type)) {
ERROR ("rrdtool plugin: DS type does not match value list type");
return -1;
DEBUG ("rrdtool plugin: queue_thread exited.");
}
- /* TODO: Maybe it'd be a good idea to free the cache here.. */
+ rrd_cache_destroy ();
return (0);
} /* int rrd_shutdown */