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_freebsd.c | |
parent | New upstream version 1.9.0+dfsg (diff) | |
download | netdata-upstream/1.10.0+dfsg.tar.xz netdata-upstream/1.10.0+dfsg.zip |
New upstream version 1.10.0+dfsgupstream/1.10.0+dfsg
Diffstat (limited to 'src/plugin_freebsd.c')
-rw-r--r-- | src/plugin_freebsd.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/plugin_freebsd.c b/src/plugin_freebsd.c index a7825d85..a0d3dc2e 100644 --- a/src/plugin_freebsd.c +++ b/src/plugin_freebsd.c @@ -66,22 +66,23 @@ static struct freebsd_module { { .name = NULL, .dim = NULL, .enabled = 0, .func = NULL } }; -void *freebsd_main(void *ptr) { +static void freebsd_main_cleanup(void *ptr) { struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr; + static_thread->enabled = NETDATA_MAIN_THREAD_EXITING; - info("FREEBSD Plugin 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 *freebsd_main(void *ptr) { + netdata_thread_cleanup_push(freebsd_main_cleanup, ptr); int vdo_cpu_netdata = config_get_boolean("plugin:freebsd", "netdata server resources", 1); // initialize FreeBSD plugin if (freebsd_plugin_init()) - netdata_exit = 1; + netdata_cleanup_and_exit(1); // check the enabled status for each module int i; @@ -97,7 +98,7 @@ void *freebsd_main(void *ptr) { heartbeat_t hb; heartbeat_init(&hb); - for(;;) { + while(!netdata_exit) { usec_t hb_dt = heartbeat_next(&hb, step); usec_t duration = 0ULL; @@ -167,9 +168,6 @@ void *freebsd_main(void *ptr) { } } - info("FREEBSD thread exiting"); - - static_thread->enabled = 0; - pthread_exit(NULL); + netdata_thread_cleanup_pop(1); return NULL; } |