summaryrefslogtreecommitdiffstats
path: root/src/plugin_nfacct.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugin_nfacct.c')
-rw-r--r--src/plugin_nfacct.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/plugin_nfacct.c b/src/plugin_nfacct.c
index 8319c6726..02815ef04 100644
--- a/src/plugin_nfacct.c
+++ b/src/plugin_nfacct.c
@@ -751,17 +751,24 @@ static void nfacct_send_metrics() {
// ----------------------------------------------------------------------------
-void *nfacct_main(void *ptr) {
+static void nfacct_main_cleanup(void *ptr) {
struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
+ static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
+ info("cleaning up...");
- info("NETFILTER thread created with task id %d", gettid());
+#ifdef DO_NFACCT
+ nfacct_cleanup();
+#endif
- if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
- error("NETFILTER: Cannot set pthread cancel type to DEFERRED.");
+#ifdef DO_NFSTAT
+ nfstat_cleanup();
+#endif
- if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
- error("NETFILTER: Cannot set pthread cancel state to ENABLE.");
+ static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
+}
+void *nfacct_main(void *ptr) {
+ netdata_thread_cleanup_push(nfacct_main_cleanup, ptr);
int update_every = (int)config_get_number("plugin:netfilter", "update every", localhost->rrd_update_every);
if(update_every < localhost->rrd_update_every)
@@ -805,18 +812,7 @@ void *nfacct_main(void *ptr) {
#endif
}
- info("NETFILTER thread exiting");
-
-#ifdef DO_NFACCT
- nfacct_cleanup();
-#endif
-
-#ifdef DO_NFSTAT
- nfstat_cleanup();
-#endif
-
- static_thread->enabled = 0;
- pthread_exit(NULL);
+ netdata_thread_cleanup_pop(1);
return NULL;
}