summaryrefslogtreecommitdiffstats
path: root/src/plugin_checks.c
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:27 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:27 +0000
commiteb7cc2640201f168bbd9a05799fd2dbe823bb57c (patch)
tree1f88da02b7ee3c16ced7b5f7dc4aadb190766e7c /src/plugin_checks.c
parentRelease v. 1.9.0+dfsg-1 to Unstable (diff)
parentNew upstream version 1.10.0+dfsg (diff)
downloadnetdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.tar.xz
netdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.zip
Update upstream source from tag 'upstream/1.10.0+dfsg'
Update to upstream version '1.10.0+dfsg' with Debian dir fa5485f3d9aea3038a19eff06ba33374ac5c5d7c
Diffstat (limited to 'src/plugin_checks.c')
-rw-r--r--src/plugin_checks.c20
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;
}