diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-07-07 16:01:34 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-07-07 16:01:34 +0300 |
commit | 74cda90e31f97ba0ebd6483f2b073c1240b93a58 (patch) | |
tree | 69727640f476822e3cc1e40ac09bf645251617be /src/nxt_runtime.c | |
parent | 61008a7c0b45fe55f3f611c61f81e569e6baee30 (diff) | |
download | unit-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 '')
-rw-r--r-- | src/nxt_runtime.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c index c707cafd..9d7a3fd7 100644 --- a/src/nxt_runtime.c +++ b/src/nxt_runtime.c @@ -445,7 +445,7 @@ nxt_single_process_start(nxt_thread_t *thr, nxt_task_t *task, nxt_runtime_t *rt) #endif - rt->type = NXT_PROCESS_SINGLE; + rt->types |= (1U << NXT_PROCESS_SINGLE); nxt_runtime_listen_sockets_enable(task, rt); @@ -479,7 +479,7 @@ nxt_runtime_quit(nxt_task_t *task) #endif - if (rt->type == NXT_PROCESS_MASTER) { + if (nxt_runtime_is_master(rt)) { nxt_master_stop_worker_processes(task, rt); done = 0; } @@ -523,7 +523,8 @@ nxt_runtime_close_idle_connections(nxt_event_engine_t *engine) static void nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) { - nxt_runtime_t *rt; + nxt_runtime_t *rt; + nxt_process_t *process; nxt_event_engine_t *engine; rt = obj; @@ -539,7 +540,7 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) #endif - if (rt->type <= NXT_PROCESS_MASTER) { + if (nxt_runtime_is_master(rt)) { if (rt->pid_file != NULL) { nxt_file_delete(rt->pid_file); } @@ -549,6 +550,14 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) nxt_event_engine_signals_stop(engine); } + nxt_runtime_process_each(rt, process) { + + nxt_runtime_process_remove(rt, process); + + } nxt_runtime_process_loop; + + nxt_mp_destroy(rt->mem_pool); + nxt_debug(task, "exit"); exit(0); @@ -1642,6 +1651,7 @@ nxt_runtime_process_remove(nxt_runtime_t *rt, nxt_process_t *process) } nxt_process_port_loop; + nxt_mp_free(rt->mem_pool, process); break; default: @@ -1683,6 +1693,20 @@ nxt_runtime_port_remove(nxt_runtime_t *rt, nxt_port_t *port) /* TODO lock ports */ nxt_port_hash_remove(&rt->ports, rt->mem_pool, port); + + if (port->pair[0] != -1) { + nxt_fd_close(port->pair[0]); + } + + if (port->pair[1] != -1) { + nxt_fd_close(port->pair[1]); + } + + if (port->mem_pool) { + nxt_mp_destroy(port->mem_pool); + } + + nxt_mp_free(port->process->mem_pool, port); } |