Browse Source

Do not try to send messages from the main signal handler to the children processes since they'll detect main disappearing and do not try to pthread join a dead thread

master
Con Kolivas 11 years ago
parent
commit
badfb12da2
  1. 17
      src/ckpool.c
  2. 3
      src/libckpool.c

17
src/ckpool.c

@ -550,25 +550,22 @@ static void shutdown_children(ckpool_t *ckp, int sig)
static void sighandler(int sig) static void sighandler(int sig)
{ {
int i; ckpool_t *ckp = global_ckp;
pthread_cancel(global_ckp->pth_watchdog);
join_pthread(global_ckp->pth_watchdog);
for (i = 0; i < global_ckp->proc_instances; i++) pthread_cancel(ckp->pth_watchdog);
send_proc(global_ckp->children[i], "shutdown"); join_pthread(ckp->pth_watchdog);
if (sig != 9) { if (sig != 9) {
/* Wait a second, then send SIGTERM */ /* Wait a second, then send SIGTERM */
sleep(1); sleep(1);
__shutdown_children(global_ckp, SIGTERM); __shutdown_children(ckp, SIGTERM);
/* Wait another second, then send SIGKILL */ /* Wait another second, then send SIGKILL */
sleep(1); sleep(1);
__shutdown_children(global_ckp, SIGKILL); __shutdown_children(ckp, SIGKILL);
pthread_cancel(global_ckp->pth_listener); pthread_cancel(ckp->pth_listener);
exit(0); exit(0);
} else { } else {
__shutdown_children(global_ckp, SIGKILL); __shutdown_children(ckp, SIGKILL);
exit(1); exit(1);
} }
} }

3
src/libckpool.c

@ -71,7 +71,8 @@ void create_pthread(pthread_t *thread, void *(*start_routine)(void *), void *arg
void join_pthread(pthread_t thread) void join_pthread(pthread_t thread)
{ {
pthread_join(thread, NULL); if (!pthread_kill(thread, 0))
pthread_join(thread, NULL);
} }

Loading…
Cancel
Save