summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_master_process.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-07-07 16:01:34 +0300
committerMax Romanov <max.romanov@nginx.com>2017-07-07 16:01:34 +0300
commit74cda90e31f97ba0ebd6483f2b073c1240b93a58 (patch)
tree69727640f476822e3cc1e40ac09bf645251617be /src/nxt_master_process.c
parent61008a7c0b45fe55f3f611c61f81e569e6baee30 (diff)
downloadunit-74cda90e31f97ba0ebd6483f2b073c1240b93a58.tar.gz
unit-74cda90e31f97ba0ebd6483f2b073c1240b93a58.tar.bz2
Process stop notification from master to all other processes.
New port message type introduced NXT_PORT_MSG_REMOVE_PID. Default handler removes process description from nxt_runtime_t with all ports, incoming and outgoing mmaps etc.
Diffstat (limited to 'src/nxt_master_process.c')
-rw-r--r--src/nxt_master_process.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/nxt_master_process.c b/src/nxt_master_process.c
index d2262a1b..c9617c9f 100644
--- a/src/nxt_master_process.c
+++ b/src/nxt_master_process.c
@@ -51,7 +51,7 @@ nxt_master_process_start(nxt_thread_t *thr, nxt_task_t *task,
{
nxt_int_t ret;
- rt->type = NXT_PROCESS_MASTER;
+ rt->types |= (1U << NXT_PROCESS_MASTER);
if (nxt_master_process_port_create(task, rt) != NXT_OK) {
return NXT_ERROR;
@@ -467,6 +467,7 @@ nxt_master_process_sigchld_handler(nxt_task_t *task, void *obj, void *data)
static void
nxt_master_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid)
{
+ nxt_port_t *port;
nxt_runtime_t *rt;
nxt_process_t *process;
nxt_process_init_t *init;
@@ -478,10 +479,23 @@ nxt_master_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid)
if (process) {
init = process->init;
- /* TODO: free ports fds. */
-
nxt_runtime_process_remove(rt, process);
+ if (!nxt_exiting) {
+ nxt_runtime_process_each(rt, process)
+ {
+ if (process->pid == nxt_pid) {
+ continue;
+ }
+
+ port = nxt_process_port_first(process);
+
+ nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID,
+ -1, pid, 0, NULL);
+ }
+ nxt_runtime_process_loop;
+ }
+
if (nxt_exiting) {
if (rt->nprocesses == 2) {