@cryptotaxi247 / netdata-1 / commits / a01364a86

Clean instances (#9081)

Brings function used to clean export instances.

thiagoftsm committed May 18, 2020 at 20:48 UTC a01364a8629856fe4e7ac5a381eb17461f78f0e7
4 files changed +41
CMakeLists.txt
+1
@@ -665,6 +665,7 @@ set(EXPORTING_ENGINE_FILES
665 exporting/prometheus/prometheus.c
666 exporting/prometheus/prometheus.h
667 exporting/read_config.c
668 + exporting/clean_connectors.c
669 exporting/init_connectors.c
670 exporting/process_data.c
671 exporting/check_filters.c
Makefile.am
+1
@@ -517,6 +517,7 @@ EXPORTING_ENGINE_FILES = \
517 exporting/prometheus/prometheus.c \
518 exporting/prometheus/prometheus.h \
519 exporting/read_config.c \
520 + exporting/clean_connectors.c \
521 exporting/init_connectors.c \
522 exporting/process_data.c \
523 exporting/check_filters.c \
exporting/clean_connectors.c new
+37
@@ -0,0 +1,37 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "exporting_engine.h"
4 +
5 +/**
6 + * Clean the instance config.
7 + * @param ptr
8 + */
9 +static void clean_instance_config(struct instance_config *ptr)
10 +{
11 + if (ptr->name)
12 + freez((void *)ptr->name);
13 +
14 + if (ptr->destination)
15 + freez((void *)ptr->destination);
16 +
17 + if (ptr->charts_pattern)
18 + simple_pattern_free(ptr->charts_pattern);
19 +
20 + if (ptr->hosts_pattern)
21 + simple_pattern_free(ptr->hosts_pattern);
22 +}
23 +
24 +/**
25 + * Clean the allocated variables
26 + *
27 + * @param ptr a pointer to the structure with variables to clean.
28 + */
29 +void clean_instance(struct instance *ptr)
30 +{
31 + clean_instance_config(&ptr->config);
32 + if (ptr->labels)
33 + buffer_free(ptr->labels);
34 +
35 + uv_mutex_destroy(&ptr->mutex);
36 + uv_cond_destroy(&ptr->cond_var);
37 +}
exporting/exporting_engine.h
+2
@@ -235,6 +235,8 @@ void create_main_rusage_chart(RRDSET **st_rusage, RRDDIM **rd_user, RRDDIM **rd_
235 void send_main_rusage(RRDSET *st_rusage, RRDDIM *rd_user, RRDDIM *rd_system);
236 void send_internal_metrics(struct instance *instance);
237
238 +extern void clean_instance(struct instance *ptr);
239 +
240 static inline void disable_instance(struct instance *instance)
241 {
242 instance->disabled = 1;