@cryptotaxi247 / netdata-1 / commits / 4eef30bf4

disconnect sending socket when the receiving has been disconnected

Costa Tsaousis (ktsaou) committed Feb 25, 2017 at 13:09 UTC 4eef30bf4a5047fde632fa7a217f65e46026f5b9
1 file changed +9 -4
src/rrdpush.c
+9 -4
@@ -37,8 +37,6 @@ int rrdpush_init() {
37 if(default_rrdpush_enabled && (!default_rrdpush_destination || !*default_rrdpush_destination || !default_rrdpush_api_key || !*default_rrdpush_api_key)) {
38 error("STREAM [send]: cannot enable sending thread - information is missing.");
39 default_rrdpush_enabled = 0;
40 - default_rrdpush_api_key = NULL;
41 - default_rrdpush_destination = NULL;
40 }
41
42 return default_rrdpush_enabled;
@@ -545,8 +543,15 @@ int rrdpush_receive(int fd, const char *key, const char *hostname, const char *m
543
544 rrdhost_wrlock(host);
545 host->use_counter--;
548 - if(!host->use_counter && health_enabled == CONFIG_BOOLEAN_AUTO)
549 - host->health_enabled = 0;
546 + if(!host->use_counter) {
547 + if(health_enabled == CONFIG_BOOLEAN_AUTO)
548 + host->health_enabled = 0;
549 +
550 + if(host->rrdpush_enabled && host->rrdpush_spawn) {
551 + pthread_cancel(host->rrdpush_thread);
552 + rrdpush_sender_thread_cleanup(host);
553 + }
554 + }
555 rrdhost_unlock(host);
556
557 // cleanup