From aa2fe8ccbfcb117efa207d10229eeeac5d0f97c7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 Feb 2023 17:11:30 +0100 Subject: Adding upstream version 1.38.0. Signed-off-by: Daniel Baumann --- database/rrdfunctions.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'database/rrdfunctions.c') diff --git a/database/rrdfunctions.c b/database/rrdfunctions.c index fb847a356..a8341f87e 100644 --- a/database/rrdfunctions.c +++ b/database/rrdfunctions.c @@ -424,7 +424,9 @@ static bool rrd_functions_conflict_callback(const DICTIONARY_ITEM *item __maybe_ void rrdfunctions_init(RRDHOST *host) { if(host->functions) return; - host->functions = dictionary_create(DICT_OPTION_DONT_OVERWRITE_VALUE); + host->functions = dictionary_create_advanced(DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_FIXED_SIZE, + &dictionary_stats_category_functions, sizeof(struct rrd_collector_function)); + dictionary_register_insert_callback(host->functions, rrd_functions_insert_callback, host); dictionary_register_delete_callback(host->functions, rrd_functions_delete_callback, host); dictionary_register_conflict_callback(host->functions, rrd_functions_conflict_callback, host); @@ -629,7 +631,7 @@ int rrd_call_function_and_wait(RRDHOST *host, BUFFER *wb, int timeout, const cha pthread_cond_init(&tmp->cond, NULL); bool we_should_free = true; - BUFFER *temp_wb = buffer_create(PLUGINSD_LINE_MAX + 1); // we need it because we may give up on it + BUFFER *temp_wb = buffer_create(PLUGINSD_LINE_MAX + 1, &netdata_buffers_statistics.buffers_functions); // we need it because we may give up on it temp_wb->contenttype = wb->contenttype; code = rdcf->function(temp_wb, timeout, key, rdcf->collector_data, rrd_call_function_signal_when_ready, tmp); if (code == HTTP_RESP_OK) { @@ -668,13 +670,14 @@ int rrd_call_function_and_wait(RRDHOST *host, BUFFER *wb, int timeout, const cha netdata_mutex_unlock(&tmp->mutex); } else { - buffer_free(temp_wb); if(!buffer_strlen(wb)) rrd_call_function_error(wb, "Failed to send request to the collector.", code); } - if (we_should_free) + if (we_should_free) { rrd_function_call_wait_free(tmp); + buffer_free(temp_wb); + } } return code; -- cgit v1.2.3