@cryptotaxi247 / netdata-1 / commits / 6a8dcea7d

stop health monitoring while netdata exits to avoid alarms flood

Costa Tsaousis (ktsaou) committed Sep 24, 2016 at 03:43 UTC 6a8dcea7d0df301104c10efa8e4db9dad5a7633b
1 file changed +8 -2
src/health.c
+8 -2
@@ -2223,7 +2223,7 @@ void *health_main(void *ptr) {
2223 BUFFER *wb = buffer_create(100);
2224
2225 unsigned int loop = 0;
2226 - while(health_enabled) {
2226 + while(health_enabled && !netdata_exit) {
2227 loop++;
2228 debug(D_HEALTH, "Health monitoring iteration no %u started", loop);
2229
@@ -2338,7 +2338,7 @@ void *health_main(void *ptr) {
2338 }
2339 rrdhost_unlock(&localhost);
2340
2341 - if (runnable) {
2341 + if (unlikely(runnable && !netdata_exit)) {
2342 rrdhost_rdlock(&localhost);
2343
2344 for (rc = localhost.alarms; rc; rc = rc->next) {
@@ -2483,10 +2483,16 @@ void *health_main(void *ptr) {
2483 if (unlikely(pthread_setcancelstate(oldstate, NULL) != 0))
2484 error("Cannot set pthread cancel state to RESTORE (%d).", oldstate);
2485
2486 + if(unlikely(netdata_exit))
2487 + break;
2488 +
2489 // execute notifications
2490 // and cleanup
2491 health_alarm_log_process(&localhost);
2492
2493 + if(unlikely(netdata_exit))
2494 + break;
2495 +
2496 now = time(NULL);
2497 if(now < next_run) {
2498 debug(D_HEALTH, "Health monitoring iteration no %u done. Next iteration in %d secs",