X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_cache.c;h=2995501aeafd020c69082eb751b068c7661740f6;hb=a2463af54cf007072aa433c5c1833958ca6050df;hp=d0e77ef351b840a79fcd91123264c3b43670dbb2;hpb=8a277e54b4ed7bccb4b3a2e7668792cd5303d3ac;p=collectd.git diff --git a/src/utils_cache.c b/src/utils_cache.c index d0e77ef3..2995501a 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -186,6 +186,7 @@ static int uc_insert (const data_set_t *ds, const value_list_t *vl, ce = cache_alloc (ds->ds_num); if (ce == NULL) { + sfree (key_copy); ERROR ("uc_insert: cache_alloc (%i) failed.", ds->ds_num); return (-1); } @@ -261,6 +262,7 @@ int uc_check_timeout (void) { ERROR ("uc_purge: realloc failed."); c_avl_iterator_destroy (iter); + pthread_mutex_unlock (&cache_lock); return (-1); } @@ -298,15 +300,16 @@ int uc_check_timeout (void) ERROR ("uc_check_timeout: c_avl_remove (%s) failed.", keys[i]); } sfree (keys[i]); + sfree (key); cache_free (ce); } - else if (status == 1) /* persist */ + else if (status == 2) /* persist */ { DEBUG ("uc_check_timeout: %s is missing, sending notification.", keys[i]); ce->state = STATE_MISSING; } - else if (status == 2) /* do not persist */ + else if (status == 1) /* do not persist */ { if (ce->state == STATE_MISSING) { @@ -509,7 +512,7 @@ gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl) if (FORMAT_VL (name, sizeof (name), vl, ds) != 0) { - ERROR ("uc_insert: FORMAT_VL failed."); + ERROR ("utils_cache: uc_get_rate: FORMAT_VL failed."); return (NULL); } @@ -519,7 +522,7 @@ gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl) /* This is important - the caller has no other way of knowing how many * values are returned. */ - if (ret_num != ds->ds_num) + if (ret_num != (size_t) ds->ds_num) { ERROR ("utils_cache: uc_get_rate: ds[%s] has %i values, " "but uc_get_rate_by_name returned %zu.",