X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fstatsd.c;h=1eb8cb94c59df032f1615909a1341ec63cab432c;hb=3fae5596643f1e361eb18c3d65448f8bc02fdd80;hp=5b7a6f182e7cef26af41b8db2baeb26c55f95b47;hpb=12f249b209d7fa31e3a9d53315e47a2342463e0f;p=collectd.git diff --git a/src/statsd.c b/src/statsd.c index 5b7a6f18..1eb8cb94 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -29,11 +29,8 @@ #include "common.h" #include "configfile.h" #include "utils_avltree.h" -#include "utils_complain.h" #include "utils_latency.h" -#include - #include #include #include @@ -358,7 +355,7 @@ static int statsd_handle_set (char const *name, /* {{{ */ /* Make sure metric->set exists. */ if (metric->set == NULL) - metric->set = c_avl_create ((void *) strcmp); + metric->set = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (metric->set == NULL) { @@ -503,7 +500,7 @@ static int statsd_network_init (struct pollfd **ret_fds, /* {{{ */ struct pollfd *fds = NULL; size_t fds_num = 0; - struct addrinfo ai_hints; + struct addrinfo ai_hints = { 0 }; struct addrinfo *ai_list = NULL; struct addrinfo *ai_ptr; int status; @@ -512,7 +509,6 @@ static int statsd_network_init (struct pollfd **ret_fds, /* {{{ */ char const *service = (conf_service != NULL) ? conf_service : STATSD_DEFAULT_SERVICE; - memset (&ai_hints, 0, sizeof (ai_hints)); ai_hints.ai_flags = AI_PASSIVE; #ifdef AI_ADDRCONFIG ai_hints.ai_flags |= AI_ADDRCONFIG; @@ -712,7 +708,7 @@ static int statsd_init (void) /* {{{ */ { pthread_mutex_lock (&metrics_lock); if (metrics_tree == NULL) - metrics_tree = c_avl_create ((void *) strcmp); + metrics_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (!network_thread_running) { @@ -955,8 +951,6 @@ static int statsd_shutdown (void) /* {{{ */ void *key; void *value; - pthread_mutex_lock (&metrics_lock); - if (network_thread_running) { network_thread_shutdown = 1; @@ -965,6 +959,8 @@ static int statsd_shutdown (void) /* {{{ */ } network_thread_running = 0; + pthread_mutex_lock (&metrics_lock); + while (c_avl_pick (metrics_tree, &key, &value) == 0) { sfree (key);