diff options
author | Vladimir Kobal <vlad@prokk.net> | 2020-05-20 09:30:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-20 09:30:12 +0300 |
commit | 98c7260d929a2f6ad2aabb4b27f0d77d49f6cae8 (patch) | |
tree | 2f9d031655c1d6ec9cf2a93e7fb7b1ad11931bfb /exporting/send_data.c | |
parent | b8e2a6fd0f2f4c6d4fa21e313e24e5e07519e5c0 (diff) |
Prepare the main cleanup function for the exporting engine (#9099)
Diffstat (limited to 'exporting/send_data.c')
-rw-r--r-- | exporting/send_data.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/exporting/send_data.c b/exporting/send_data.c index 8875065f2b..3a749cdbb8 100644 --- a/exporting/send_data.c +++ b/exporting/send_data.c @@ -141,6 +141,21 @@ void simple_connector_send_buffer(int *sock, int *failures, struct instance *ins } /** + * 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); + + // TODO free allocated resources + + info("EXPORTING: instance %s exited", instance->config.name); + instance->exited = 1; +} + +/** * Simple connector worker * * Runs in a separate thread for every instance. @@ -159,7 +174,7 @@ void simple_connector_worker(void *instance_p) .tv_usec = (instance->config.timeoutms * 1000) % 1000000}; int failures = 0; - while(!netdata_exit) { + while(!instance->engine->exit) { // reset the monitoring chart counters stats->received_bytes = @@ -195,7 +210,7 @@ void simple_connector_worker(void *instance_p) stats->reconnects += reconnects; } - if(unlikely(netdata_exit)) break; + if(unlikely(instance->engine->exit)) break; // ------------------------------------------------------------------------ // if we are connected, send our buffer to the data collecting server @@ -203,6 +218,8 @@ void simple_connector_worker(void *instance_p) uv_mutex_lock(&instance->mutex); uv_cond_wait(&instance->cond_var, &instance->mutex); + if(unlikely(instance->engine->exit)) break; + if (likely(sock != -1)) { simple_connector_send_buffer(&sock, &failures, instance); } else { @@ -238,4 +255,6 @@ void simple_connector_worker(void *instance_p) break; #endif } + + simple_connector_cleanup(instance); } |