@cryptotaxi247 / netdata-1 / commits / c516b0aec

never NULL a pthread manually

Costa Tsaousis (ktsaou) committed Jan 21, 2017 at 22:45 UTC c516b0aec2fd3d107a40b410ca2ef4242f9ebbdf
3 files changed +8 -12
src/main.c
+8 -10
@@ -161,17 +161,19 @@ void kill_childs()
161 pthread_cancel(w->thread);
162 // it is detached
163 // pthread_join(w->thread, NULL);
164 +
165 + w->obsolete = 1;
166 }
167
168 int i;
169 for (i = 0; static_threads[i].name != NULL ; i++) {
168 - if(static_threads[i].enabled && static_threads[i].thread) {
170 + if(static_threads[i].enabled) {
171 info("Stopping %s thread", static_threads[i].name);
172 pthread_cancel(*static_threads[i].thread);
173 // it is detached
174 // pthread_join(*static_threads[i].thread, NULL);
175
174 - static_threads[i].thread = NULL;
176 + static_threads[i].enabled = 0;
177 }
178 }
179
@@ -179,19 +181,15 @@ void kill_childs()
181 info("Killing tc-qos-helper process %d", tc_child_pid);
182 if(killpid(tc_child_pid, SIGTERM) != -1)
183 waitid(P_PID, (id_t) tc_child_pid, &info, WEXITED);
184 +
185 + tc_child_pid = 0;
186 }
183 - tc_child_pid = 0;
187
188 struct plugind *cd;
189 for(cd = pluginsd_root ; cd ; cd = cd->next) {
190 if(cd->enabled && !cd->obsolete) {
188 - if(cd->thread != (pthread_t)NULL) {
189 - info("Stopping %s plugin thread", cd->id);
190 - pthread_cancel(cd->thread);
191 - // they are detached
192 - // pthread_join(cd->thread, NULL);
193 - cd->thread = (pthread_t)NULL;
194 - }
191 + info("Stopping %s plugin thread", cd->id);
192 + pthread_cancel(cd->thread);
193
194 if(cd->pid) {
195 info("killing %s plugin child process pid %d", cd->id, cd->pid);
src/main.h
-1
@@ -24,7 +24,6 @@ struct option_def {
24 */
25 extern struct option_def options[];
26
27 -
27 struct netdata_static_thread {
28 char *name;
29
src/plugins_d.c
-1
@@ -427,7 +427,6 @@ void *pluginsd_worker_thread(void *arg)
427 info("PLUGINSD: '%s' thread exiting", cd->fullfilename);
428
429 cd->obsolete = 1;
430 - cd->thread = (pthread_t)NULL;
430 pthread_exit(NULL);
431 return NULL;
432 }