summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9b43c4c)
raw | patch | inline | side by side (parent: 9b43c4c)
author | Florian Forster <octo@collectd.org> | |
Sat, 30 May 2015 21:13:42 +0000 (23:13 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 30 May 2015 21:13:42 +0000 (23:13 +0200) |
latency counters (used by TIMER metrics) and AVL trees (used by SET metrics)
were not freed when cleaning up unused metrics. This resulted in leaked memory.
Fixes: #997
were not freed when cleaning up unused metrics. This resulted in leaked memory.
Fixes: #997
src/statsd.c | patch | blob | history |
diff --git a/src/statsd.c b/src/statsd.c
index 327b8db476e0b192d0bf12ee13268d6170cbd253..ebb7c1ebd43e003c22f6bffbba1d6f9166abfa8c 100644 (file)
--- a/src/statsd.c
+++ b/src/statsd.c
return (0);
} /* }}} int statsd_metric_add */
+static void statsd_metric_free (statsd_metric_t *metric) /* {{{ */
+{
+ if (metric == NULL)
+ return;
+
+ if (metric->latency != NULL)
+ {
+ latency_counter_destroy (metric->latency);
+ metric->latency = NULL;
+ }
+
+ if (metric->set != NULL)
+ {
+ void *key;
+ void *value;
+
+ while (c_avl_pick (metric->set, &key, &value) == 0)
+ {
+ sfree (key);
+ assert (value == NULL);
+ }
+
+ c_avl_destroy (metric->set);
+ metric->set = NULL;
+ }
+
+ sfree (name);
+ sfree (metric);
+} /* }}} void statsd_metric_free */
+
static int statsd_parse_value (char const *str, value_t *ret_value) /* {{{ */
{
char *endptr = NULL;
}
sfree (name);
- sfree (metric);
+ statsd_metric_free (metric);
}
pthread_mutex_unlock (&metrics_lock);