summaryrefslogtreecommitdiffstats
path: root/src/plugin_nfacct.c
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:21 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:21 +0000
commitd4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c (patch)
treefaac99f51f182bb8c0a03e95e393d421ac9ddf42 /src/plugin_nfacct.c
parentNew upstream version 1.9.0+dfsg (diff)
downloadnetdata-d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c.tar.xz
netdata-d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c.zip
New upstream version 1.10.0+dfsgupstream/1.10.0+dfsg
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 8319c672..02815ef0 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;
}