diff options
author | Andrei Belov <defan@nginx.com> | 2019-10-03 17:46:28 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2019-10-03 17:46:28 +0300 |
commit | 3dd3f861f4c3aa320aa137802f033f8f1fc7dc41 (patch) | |
tree | 357577c560920eb0f5837b7d073999f5c7a1a2cd /src/nxt_main_process.c | |
parent | 9de7aea721245cda9f079a2b29d8efaf99c440fd (diff) | |
parent | 59db9a3887211fccdaec04b7952ad0140090de22 (diff) | |
download | unit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.gz unit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.bz2 |
Merged with the default branch.
Diffstat (limited to 'src/nxt_main_process.c')
-rw-r--r-- | src/nxt_main_process.c | 91 |
1 files changed, 48 insertions, 43 deletions
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index 44deb272..85685fbc 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -14,10 +14,6 @@ #include <nxt_cert.h> #endif -#ifdef NXT_LINUX -#include <linux/sched.h> -#endif - typedef struct { nxt_socket_t socket; @@ -661,7 +657,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt, ret = nxt_user_cred_get(task, init->user_cred, group); if (ret != NXT_OK) { - return NXT_ERROR; + goto fail; } } else { @@ -670,7 +666,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt, { nxt_alert(task, "cannot set user \"%V\" for app \"%V\": " "missing capabilities", &app_conf->user, &app_conf->name); - return NXT_ERROR; + goto fail; } if (app_conf->group.length > 0 @@ -680,7 +676,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt, nxt_alert(task, "cannot set group \"%V\" for app \"%V\": " "missing capabilities", &app_conf->group, &app_conf->name); - return NXT_ERROR; + goto fail; } last = nxt_pointer_to(init, sizeof(nxt_process_init_t)); @@ -702,10 +698,16 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt, ret = nxt_init_set_isolation(task, init, app_conf->isolation); if (nxt_slow_path(ret != NXT_OK)) { - return NXT_ERROR; + goto fail; } return nxt_main_create_worker_process(task, rt, init); + +fail: + + nxt_free(init); + + return NXT_ERROR; } @@ -1012,52 +1014,50 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid) nxt_process_close_ports(task, process); - if (!nxt_exiting) { - nxt_runtime_process_each(rt, process) { - - if (process->pid == nxt_pid - || process->pid == pid - || nxt_queue_is_empty(&process->ports)) - { - continue; - } - - port = nxt_process_port_first(process); + if (nxt_exiting) { + if (rt->nprocesses <= 2) { + nxt_runtime_quit(task, 0); + } - if (nxt_proc_remove_notify_matrix[ptype][port->type] == 0) { - continue; - } + return; + } - buf = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool, - sizeof(pid)); - if (nxt_slow_path(buf == NULL)) { - continue; - } + nxt_runtime_process_each(rt, process) { - buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid)); + if (process->pid == nxt_pid + || process->pid == pid + || nxt_queue_is_empty(&process->ports)) + { + continue; + } - nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID, - -1, init->stream, 0, buf); - } nxt_runtime_process_loop; - } + port = nxt_process_port_first(process); - if (nxt_exiting) { + if (nxt_proc_remove_notify_matrix[ptype][port->type] == 0) { + continue; + } - if (rt->nprocesses == 2) { - nxt_runtime_quit(task, 0); + buf = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool, + sizeof(pid)); + if (nxt_slow_path(buf == NULL)) { + continue; } - } else if (init != NULL) { - if (init->restart != NULL) { - if (init->type == NXT_PROCESS_ROUTER) { - nxt_main_stop_worker_processes(task, rt); - } + buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid)); - init->restart(task, rt, init); + nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID, + -1, init->stream, 0, buf); + } nxt_runtime_process_loop; - } else { - nxt_free(init); + if (init->restart != NULL) { + if (init->type == NXT_PROCESS_ROUTER) { + nxt_main_stop_worker_processes(task, rt); } + + init->restart(task, rt, init); + + } else { + nxt_free(init); } } } @@ -1311,6 +1311,11 @@ nxt_main_port_modules_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) return; } + if (nxt_exiting) { + nxt_debug(task, "ignoring discovered modules, exiting"); + return; + } + port = nxt_runtime_port_find(task->thread->runtime, msg->port_msg.pid, msg->port_msg.reply_port); |