diff options
-rw-r--r-- | src/nxt_main_process.c | 28 | ||||
-rw-r--r-- | src/nxt_main_process.h | 2 | ||||
-rw-r--r-- | src/nxt_runtime.c | 2 |
3 files changed, 29 insertions, 3 deletions
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index 27d17779..31e7ca9a 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -50,6 +50,7 @@ static void nxt_main_process_sigusr1_handler(nxt_task_t *task, void *obj, static void nxt_main_process_sigchld_handler(nxt_task_t *task, void *obj, void *data); static void nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid); +static void nxt_main_stop_worker_processes(nxt_task_t *task, nxt_runtime_t *rt); static void nxt_main_port_socket_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg); static nxt_int_t nxt_main_listening_socket(nxt_sockaddr_t *sa, @@ -661,7 +662,7 @@ nxt_main_create_worker_process(nxt_task_t *task, nxt_runtime_t *rt, void -nxt_main_stop_worker_processes(nxt_task_t *task, nxt_runtime_t *rt) +nxt_main_stop_all_processes(nxt_task_t *task, nxt_runtime_t *rt) { nxt_port_t *port; nxt_process_t *process; @@ -923,6 +924,10 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid) } else if (init != NULL) { if (init->restart != NULL) { + if (init->type == NXT_PROCESS_ROUTER) { + nxt_main_stop_worker_processes(task, rt); + } + init->restart(task, rt, init); } else { @@ -934,6 +939,27 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid) static void +nxt_main_stop_worker_processes(nxt_task_t *task, nxt_runtime_t *rt) +{ + nxt_port_t *port; + nxt_process_t *process; + + nxt_runtime_process_each(rt, process) { + + nxt_process_port_each(process, port) { + + if (port->type == NXT_PROCESS_WORKER) { + (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_QUIT, + -1, 0, 0, NULL); + } + + } nxt_process_port_loop; + + } nxt_runtime_process_loop; +} + + +static void nxt_main_port_socket_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) { size_t size; diff --git a/src/nxt_main_process.h b/src/nxt_main_process.h index 54861a60..9d74787e 100644 --- a/src/nxt_main_process.h +++ b/src/nxt_main_process.h @@ -21,7 +21,7 @@ typedef enum { nxt_int_t nxt_main_process_start(nxt_thread_t *thr, nxt_task_t *task, nxt_runtime_t *runtime); -void nxt_main_stop_worker_processes(nxt_task_t *task, nxt_runtime_t *runtime); +void nxt_main_stop_all_processes(nxt_task_t *task, nxt_runtime_t *runtime); nxt_int_t nxt_controller_start(nxt_task_t *task, void *data); nxt_int_t nxt_router_start(nxt_task_t *task, void *data); diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c index 4923c965..acc2820a 100644 --- a/src/nxt_runtime.c +++ b/src/nxt_runtime.c @@ -435,7 +435,7 @@ nxt_runtime_quit(nxt_task_t *task, nxt_uint_t status) } if (rt->type == NXT_PROCESS_MAIN) { - nxt_main_stop_worker_processes(task, rt); + nxt_main_stop_all_processes(task, rt); done = 0; } } |