blob: ab1fb5dd7b7ca59b0f51c0e8220c83375c093d13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// SPDX-License-Identifier: GPL-3.0-or-later
#include "exporting_engine.h"
/**
* Clean the instance config.
*
* @param config an instance config structure.
*/
static void clean_instance_config(struct instance_config *config)
{
if(!config)
return;
freez((void *)config->type_name);
freez((void *)config->name);
freez((void *)config->destination);
freez((void *)config->username);
freez((void *)config->password);
freez((void *)config->prefix);
freez((void *)config->hostname);
simple_pattern_free(config->charts_pattern);
simple_pattern_free(config->hosts_pattern);
}
/**
* Clean the allocated variables
*
* @param instance an instance data structure.
*/
void clean_instance(struct instance *instance)
{
clean_instance_config(&instance->config);
buffer_free(instance->labels_buffer);
uv_cond_destroy(&instance->cond_var);
// uv_mutex_destroy(&instance->mutex);
}
/**
* Clean up a simple connector instance on Netdata exit
*
* @param instance an instance data structure.
*/
void simple_connector_cleanup(struct instance *instance)
{
info("EXPORTING: cleaning up instance %s ...", instance->config.name);
struct simple_connector_data *simple_connector_data =
(struct simple_connector_data *)instance->connector_specific_data;
freez(simple_connector_data->auth_string);
buffer_free(instance->buffer);
buffer_free(simple_connector_data->buffer);
buffer_free(simple_connector_data->header);
struct simple_connector_buffer *next_buffer = simple_connector_data->first_buffer;
for (int i = 0; i < instance->config.buffer_on_failures; i++) {
struct simple_connector_buffer *current_buffer = next_buffer;
next_buffer = next_buffer->next;
buffer_free(current_buffer->header);
buffer_free(current_buffer->buffer);
freez(current_buffer);
}
#ifdef ENABLE_HTTPS
netdata_ssl_close(&simple_connector_data->ssl);
#endif
freez(simple_connector_data);
struct simple_connector_config *simple_connector_config =
(struct simple_connector_config *)instance->config.connector_specific_config;
freez(simple_connector_config);
info("EXPORTING: instance %s exited", instance->config.name);
instance->exited = 1;
}
|