]> arthur.barton.de Git - netdata.git/commitdiff
never NULL a pthread manually
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 21 Jan 2017 20:45:58 +0000 (22:45 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 21 Jan 2017 20:45:58 +0000 (22:45 +0200)
src/main.c
src/main.h
src/plugins_d.c

index 1dcd3f7841469836bc0f49d6dfd555d92661f817..ca134fcb05fddd60bbe331768237d6e21bca4abd 100644 (file)
@@ -161,17 +161,19 @@ void kill_childs()
         pthread_cancel(w->thread);
         // it is detached
         // pthread_join(w->thread, NULL);
+
+        w->obsolete = 1;
     }
 
     int i;
     for (i = 0; static_threads[i].name != NULL ; i++) {
-        if(static_threads[i].enabled && static_threads[i].thread) {
+        if(static_threads[i].enabled) {
             info("Stopping %s thread", static_threads[i].name);
             pthread_cancel(*static_threads[i].thread);
             // it is detached
             // pthread_join(*static_threads[i].thread, NULL);
 
-            static_threads[i].thread = NULL;
+            static_threads[i].enabled = 0;
         }
     }
 
@@ -179,19 +181,15 @@ void kill_childs()
         info("Killing tc-qos-helper process %d", tc_child_pid);
         if(killpid(tc_child_pid, SIGTERM) != -1)
             waitid(P_PID, (id_t) tc_child_pid, &info, WEXITED);
+
+        tc_child_pid = 0;
     }
-    tc_child_pid = 0;
 
     struct plugind *cd;
     for(cd = pluginsd_root ; cd ; cd = cd->next) {
         if(cd->enabled && !cd->obsolete) {
-            if(cd->thread != (pthread_t)NULL) {
-                info("Stopping %s plugin thread", cd->id);
-                pthread_cancel(cd->thread);
-                // they are detached
-                // pthread_join(cd->thread, NULL);
-                cd->thread = (pthread_t)NULL;
-            }
+            info("Stopping %s plugin thread", cd->id);
+            pthread_cancel(cd->thread);
 
             if(cd->pid) {
                 info("killing %s plugin child process pid %d", cd->id, cd->pid);
index 288536baa914b47727806d45d5a3a4f38a42fb11..49afaef123e7ce6a6546bc763c78ab4f722f14d6 100644 (file)
@@ -24,7 +24,6 @@ struct option_def {
  */
 extern struct option_def options[];
 
-
 struct netdata_static_thread {
     char *name;
 
index 276f92e1d955c2d9675172bbb9a363cde0f8e7c3..4b83b5281616058afa2d26b7e22c32b1a60f8ea1 100644 (file)
@@ -427,7 +427,6 @@ void *pluginsd_worker_thread(void *arg)
     info("PLUGINSD: '%s' thread exiting", cd->fullfilename);
 
     cd->obsolete = 1;
-    cd->thread = (pthread_t)NULL;
     pthread_exit(NULL);
     return NULL;
 }