diff options
-rw-r--r-- | src/nxt_main_process.c | 6 | ||||
-rw-r--r-- | src/nxt_port.c | 2 | ||||
-rw-r--r-- | src/nxt_runtime.c | 21 | ||||
-rw-r--r-- | src/nxt_runtime.h | 6 | ||||
-rw-r--r-- | src/nxt_worker_process.c | 4 |
5 files changed, 22 insertions, 17 deletions
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index 71a871df..27d17779 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -694,7 +694,7 @@ nxt_main_process_sigterm_handler(nxt_task_t *task, void *obj, void *data) nxt_exiting = 1; - nxt_runtime_quit(task); + nxt_runtime_quit(task, 0); } @@ -708,7 +708,7 @@ nxt_main_process_sigquit_handler(nxt_task_t *task, void *obj, void *data) nxt_exiting = 1; - nxt_runtime_quit(task); + nxt_runtime_quit(task, 0); } @@ -918,7 +918,7 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid) if (nxt_exiting) { if (rt->nprocesses == 2) { - nxt_runtime_quit(task); + nxt_runtime_quit(task, 0); } } else if (init != NULL) { diff --git a/src/nxt_port.c b/src/nxt_port.c index 6ccdfab5..ae08b71d 100644 --- a/src/nxt_port.c +++ b/src/nxt_port.c @@ -177,7 +177,7 @@ nxt_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) void nxt_port_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) { - nxt_runtime_quit(task); + nxt_runtime_quit(task, 0); } diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c index 849499d8..1dfe2f61 100644 --- a/src/nxt_runtime.c +++ b/src/nxt_runtime.c @@ -19,7 +19,7 @@ static nxt_int_t nxt_runtime_systemd_listen_sockets(nxt_task_t *task, static nxt_int_t nxt_runtime_event_engines(nxt_task_t *task, nxt_runtime_t *rt); static nxt_int_t nxt_runtime_thread_pools(nxt_thread_t *thr, nxt_runtime_t *rt); static void nxt_runtime_start(nxt_task_t *task, void *obj, void *data); -static void nxt_runtime_initial_start(nxt_task_t *task); +static void nxt_runtime_initial_start(nxt_task_t *task, nxt_uint_t status); static void nxt_runtime_close_idle_connections(nxt_event_engine_t *engine); static void nxt_runtime_exit(nxt_task_t *task, void *obj, void *data); static nxt_int_t nxt_runtime_event_engine_change(nxt_task_t *task, @@ -351,12 +351,12 @@ nxt_runtime_start(nxt_task_t *task, void *obj, void *data) fail: - nxt_runtime_quit(task); + nxt_runtime_quit(task, 1); } static void -nxt_runtime_initial_start(nxt_task_t *task) +nxt_runtime_initial_start(nxt_task_t *task, nxt_uint_t status) { nxt_int_t ret; nxt_thread_t *thr; @@ -407,18 +407,19 @@ nxt_runtime_initial_start(nxt_task_t *task) fail: - nxt_runtime_quit(task); + nxt_runtime_quit(task, 1); } void -nxt_runtime_quit(nxt_task_t *task) +nxt_runtime_quit(nxt_task_t *task, nxt_uint_t status) { nxt_bool_t done; nxt_runtime_t *rt; nxt_event_engine_t *engine; rt = task->thread->runtime; + rt->status |= status; engine = task->thread->engine; nxt_debug(task, "exiting"); @@ -477,6 +478,7 @@ nxt_runtime_close_idle_connections(nxt_event_engine_t *engine) static void nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) { + int status; nxt_runtime_t *rt; nxt_process_t *process; nxt_event_engine_t *engine; @@ -522,11 +524,12 @@ nxt_runtime_exit(nxt_task_t *task, void *obj, void *data) nxt_thread_mutex_destroy(&rt->processes_mutex); + status = rt->status; nxt_mp_destroy(rt->mem_pool); - nxt_debug(task, "exit"); + nxt_debug(task, "exit: %d", status); - exit(0); + exit(status); nxt_unreachable(); } @@ -605,7 +608,7 @@ nxt_runtime_thread_pool_destroy(nxt_task_t *task, nxt_runtime_t *rt, n = rt->thread_pools->nelts; if (n == 0) { - cont(task); + cont(task, 0); return; } @@ -658,7 +661,7 @@ nxt_runtime_thread_pool_exit(nxt_task_t *task, void *obj, void *data) if (n == 1) { /* The last thread pool. */ - rt->continuation(task); + rt->continuation(task, 0); } return; diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h index c23e4bce..dbad16b0 100644 --- a/src/nxt_runtime.h +++ b/src/nxt_runtime.h @@ -9,7 +9,7 @@ #define _NXT_RUNTIME_H_INCLUDED_ -typedef void (*nxt_runtime_cont_t)(nxt_task_t *task); +typedef void (*nxt_runtime_cont_t)(nxt_task_t *task, nxt_uint_t status); struct nxt_runtime_s { @@ -49,6 +49,8 @@ struct nxt_runtime_s { uint8_t daemon; uint8_t batch; + uint8_t status; + const char *engine; uint32_t engine_connections; uint32_t auxiliary_threads; @@ -75,7 +77,7 @@ typedef nxt_int_t (*nxt_module_init_t)(nxt_thread_t *thr, nxt_runtime_t *rt); nxt_int_t nxt_runtime_create(nxt_task_t *task); -void nxt_runtime_quit(nxt_task_t *task); +void nxt_runtime_quit(nxt_task_t *task, nxt_uint_t status); void nxt_runtime_event_engine_free(nxt_runtime_t *rt); diff --git a/src/nxt_worker_process.c b/src/nxt_worker_process.c index bf35f2b5..7ba92dea 100644 --- a/src/nxt_worker_process.c +++ b/src/nxt_worker_process.c @@ -97,7 +97,7 @@ nxt_worker_process_quit(nxt_task_t *task) rt->listen_sockets->nelts = 0; } - nxt_runtime_quit(task); + nxt_runtime_quit(task, 0); } @@ -124,7 +124,7 @@ nxt_worker_process_sigterm_handler(nxt_task_t *task, void *obj, void *data) /* A fast exit. */ - nxt_runtime_quit(task); + nxt_runtime_quit(task, 0); } |