diff options
author | Federico Ceratto <federico.ceratto@gmail.com> | 2018-03-27 21:28:21 +0000 |
---|---|---|
committer | Federico Ceratto <federico.ceratto@gmail.com> | 2018-03-27 21:28:21 +0000 |
commit | d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c (patch) | |
tree | faac99f51f182bb8c0a03e95e393d421ac9ddf42 /src/plugin_checks.c | |
parent | New upstream version 1.9.0+dfsg (diff) | |
download | netdata-d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c.tar.xz netdata-d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c.zip |
New upstream version 1.10.0+dfsgupstream/1.10.0+dfsg
Diffstat (limited to 'src/plugin_checks.c')
-rw-r--r-- | src/plugin_checks.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/plugin_checks.c b/src/plugin_checks.c index 9c1e42cc6..b99b97d40 100644 --- a/src/plugin_checks.c +++ b/src/plugin_checks.c @@ -2,16 +2,17 @@ #ifdef NETDATA_INTERNAL_CHECKS -void *checks_main(void *ptr) { +static void checks_main_cleanup(void *ptr) { struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr; + static_thread->enabled = NETDATA_MAIN_THREAD_EXITING; - info("CHECKS thread created with task id %d", gettid()); + info("cleaning up..."); - if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0) - error("Cannot set pthread cancel type to DEFERRED."); + static_thread->enabled = NETDATA_MAIN_THREAD_EXITED; +} - if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0) - error("Cannot set pthread cancel state to ENABLE."); +void *checks_main(void *ptr) { + netdata_thread_cleanup_push(checks_main_cleanup, ptr); usec_t usec = 0, susec = localhost->rrd_update_every * USEC_PER_SEC, loop_usec = 0, total_susec = 0; struct timeval now, last, loop; @@ -72,7 +73,7 @@ void *checks_main(void *ptr) { rrddim_add(check3, "apps.plugin", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); now_realtime_timeval(&last); - while(1) { + while(!netdata_exit) { usleep(susec); // find the time to sleep in order to wait exactly update_every seconds @@ -119,10 +120,7 @@ void *checks_main(void *ptr) { rrdset_done(check3); } - info("CHECKS thread exiting"); - - static_thread->enabled = 0; - pthread_exit(NULL); + netdata_thread_cleanup_pop(1); return NULL; } |