summaryrefslogtreecommitdiffstats
path: root/src/collectors/macos.plugin/plugin_macos.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/collectors/macos.plugin/plugin_macos.c (renamed from collectors/macos.plugin/plugin_macos.c)19
1 files changed, 11 insertions, 8 deletions
diff --git a/collectors/macos.plugin/plugin_macos.c b/src/collectors/macos.plugin/plugin_macos.c
index 3aaa46c72..0d651ae69 100644
--- a/collectors/macos.plugin/plugin_macos.c
+++ b/src/collectors/macos.plugin/plugin_macos.c
@@ -25,23 +25,24 @@ static struct macos_module {
#error WORKER_UTILIZATION_MAX_JOB_TYPES has to be at least 3
#endif
-static void macos_main_cleanup(void *ptr)
+static void macos_main_cleanup(void *pptr)
{
- worker_unregister();
+ struct netdata_static_thread *static_thread = CLEANUP_FUNCTION_GET_PTR(pptr);
+ if(!static_thread) return;
- struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
collector_info("cleaning up...");
+ worker_unregister();
static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
}
void *macos_main(void *ptr)
{
- worker_register("MACOS");
+ CLEANUP_FUNCTION_REGISTER(macos_main_cleanup) cleanup_ptr = ptr;
- netdata_thread_cleanup_push(macos_main_cleanup, ptr);
+ worker_register("MACOS");
// check the enabled status for each module
for (int i = 0; macos_modules[i].name; i++) {
@@ -57,10 +58,13 @@ void *macos_main(void *ptr)
heartbeat_t hb;
heartbeat_init(&hb);
- while (!netdata_exit) {
+ while(service_running(SERVICE_COLLECTORS)) {
worker_is_idle();
usec_t hb_dt = heartbeat_next(&hb, step);
+ if (!service_running(SERVICE_COLLECTORS))
+ break;
+
for (int i = 0; macos_modules[i].name; i++) {
struct macos_module *pm = &macos_modules[i];
if (unlikely(!pm->enabled))
@@ -71,11 +75,10 @@ void *macos_main(void *ptr)
worker_is_busy(i);
pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
- if (unlikely(netdata_exit))
+ if (!service_running(SERVICE_COLLECTORS))
break;
}
}
- netdata_thread_cleanup_pop(1);
return NULL;
}