summaryrefslogtreecommitdiffstats
path: root/database/rrdfunctions.c
diff options
context:
space:
mode:
Diffstat (limited to 'database/rrdfunctions.c')
-rw-r--r--database/rrdfunctions.c11
1 files changed, 7 insertions, 4 deletions
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;