summaryrefslogtreecommitdiffstats
path: root/src/plugin_macos.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_macos.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_macos.c')
-rw-r--r--src/plugin_macos.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/plugin_macos.c b/src/plugin_macos.c
index 4e84a084d..6ac3d25d1 100644
--- a/src/plugin_macos.c
+++ b/src/plugin_macos.c
@@ -1,15 +1,16 @@
#include "common.h"
-void *macos_main(void *ptr) {
+static void macos_main_cleanup(void *ptr) {
struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
+ static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
- info("MACOS 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 *macos_main(void *ptr) {
+ netdata_thread_cleanup_push(macos_main_cleanup, ptr);
// when ZERO, attempt to do it
int vdo_cpu_netdata = !config_get_boolean("plugin:macos", "netdata server resources", 1);
@@ -25,7 +26,8 @@ void *macos_main(void *ptr) {
usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
heartbeat_t hb;
heartbeat_init(&hb);
- for(;;) {
+
+ while(!netdata_exit) {
usec_t hb_dt = heartbeat_next(&hb, step);
if(unlikely(netdata_exit)) break;
@@ -60,9 +62,6 @@ void *macos_main(void *ptr) {
}
}
- info("MACOS thread exiting");
-
- static_thread->enabled = 0;
- pthread_exit(NULL);
+ netdata_thread_cleanup_pop(1);
return NULL;
}