]> arthur.barton.de Git - netdata.git/blobdiff - src/plugins_d.c
added pthread_exit in hope it will solve the crash at exit
[netdata.git] / src / plugins_d.c
index ef43ab1a04ab48e6cc1c47ea8dff8e91cb2cedff..b4cb57888d7c52296bb6a7af1eb610ff3ffad894 100755 (executable)
@@ -125,6 +125,8 @@ void *pluginsd_worker_thread(void *arg)
 #endif
 
        while(likely(1)) {
+               if(unlikely(netdata_exit)) break;
+
                FILE *fp = mypopen(cd->cmd, &cd->pid);
                if(unlikely(!fp)) {
                        error("Cannot popen(\"%s\", \"r\").", cd->cmd);
@@ -139,7 +141,7 @@ void *pluginsd_worker_thread(void *arg)
                uint32_t hash;
 
                while(likely(fgets(line, PLUGINSD_LINE_MAX, fp) != NULL)) {
-                       if(netdata_exit) break;
+                       if(unlikely(netdata_exit)) break;
 
                        line[PLUGINSD_LINE_MAX] = '\0';
 
@@ -226,8 +228,12 @@ void *pluginsd_worker_thread(void *arg)
                                st = NULL;
                        }
                        else if(likely(hash == CHART_HASH && !strcmp(s, "CHART"))) {
+                               int noname = 0;
                                st = NULL;
 
+                               if((words[1]) != NULL && (words[2]) != NULL && strcmp(words[1], words[2]) == 0)
+                                       noname = 1;
+
                                char *type = words[1];
                                char *id = NULL;
                                if(likely(type)) {
@@ -260,7 +266,7 @@ void *pluginsd_worker_thread(void *arg)
                                int chart_type = RRDSET_TYPE_LINE;
                                if(unlikely(chart)) chart_type = rrdset_type_id(chart);
 
-                               if(unlikely(!name || !*name)) name = NULL;
+                               if(unlikely(noname || !name || !*name || strcasecmp(name, "NULL") == 0 || strcasecmp(name, "(NULL)") == 0)) name = NULL;
                                if(unlikely(!family || !*family)) family = id;
                                if(unlikely(!category || !*category)) category = type;
 
@@ -397,6 +403,7 @@ void *pluginsd_worker_thread(void *arg)
                        cd->pid = 0;
                        cd->enabled = 0;
                        cd->obsolete = 1;
+                       pthread_exit(NULL);
                        return NULL;
                }
 
@@ -411,6 +418,7 @@ void *pluginsd_worker_thread(void *arg)
        }
 
        cd->obsolete = 1;
+       pthread_exit(NULL);
        return NULL;
 }
 
@@ -439,16 +447,17 @@ void *pluginsd_main(void *ptr)
        if(scan_frequency < 1) scan_frequency = 1;
 
        while(likely(1)) {
-               if(netdata_exit) break;
+               if(unlikely(netdata_exit)) break;
 
                dir = opendir(dir_name);
                if(unlikely(!dir)) {
                        error("Cannot open directory '%s'.", dir_name);
+                       pthread_exit(NULL);
                        return NULL;
                }
 
                while(likely((file = readdir(dir)))) {
-                       if(netdata_exit) break;
+                       if(unlikely(netdata_exit)) break;
 
                        debug(D_PLUGINSD, "PLUGINSD: Examining file '%s'", file->d_name);
 
@@ -518,6 +527,7 @@ void *pluginsd_main(void *ptr)
                sleep((unsigned int) scan_frequency);
        }
 
+       pthread_exit(NULL);
        return NULL;
 }