]> arthur.barton.de Git - netdata.git/blobdiff - src/plugin_nfacct.c
added pthread_exit in hope it will solve the crash at exit
[netdata.git] / src / plugin_nfacct.c
index c088069a3284f11fa0a15f5ee94318a10b3365a6..0c5b39457b38cb83cf6f44289b71eabdbd17ebbb 100644 (file)
@@ -98,12 +98,14 @@ void *nfacct_main(void *ptr) {
        nl  = mnl_socket_open(NETLINK_NETFILTER);
        if(!nl) {
                error("nfacct.plugin: mnl_socket_open() failed");
+               pthread_exit(NULL);
                return NULL;
        }
 
        if(mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
                mnl_socket_close(nl);
                error("nfacct.plugin: mnl_socket_bind() failed");
+               pthread_exit(NULL);
                return NULL;
        }
        portid = mnl_socket_get_portid(nl);
@@ -119,17 +121,21 @@ void *nfacct_main(void *ptr) {
        // ------------------------------------------------------------------------
 
        while(1) {
+               if(unlikely(netdata_exit)) break;
+
                seq++;
 
                nlh = nfacct_nlmsg_build_hdr(buf, NFNL_MSG_ACCT_GET, NLM_F_DUMP, seq);
                if(!nlh) {
                        mnl_socket_close(nl);
                        error("nfacct.plugin: nfacct_nlmsg_build_hdr() failed");
+                       pthread_exit(NULL);
                        return NULL;
                }
 
                if(mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
                        error("nfacct.plugin: mnl_socket_send");
+                       pthread_exit(NULL);
                        return NULL;
                }
 
@@ -142,6 +148,7 @@ void *nfacct_main(void *ptr) {
 
                if (ret == -1) {
                        error("nfacct.plugin: error communicating with kernel.");
+                       pthread_exit(NULL);
                        return NULL;
                }
 
@@ -208,6 +215,7 @@ void *nfacct_main(void *ptr) {
        }
 
        mnl_socket_close(nl);
+       pthread_exit(NULL);
        return NULL;
 }
 #endif