diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nxt_application.c | 13 | ||||
-rw-r--r-- | src/nxt_application.h | 1 | ||||
-rw-r--r-- | src/nxt_go.c | 1 | ||||
-rw-r--r-- | src/nxt_php_sapi.c | 1 | ||||
-rw-r--r-- | src/nxt_python_wsgi.c | 18 | ||||
-rw-r--r-- | src/nxt_runtime.h | 3 | ||||
-rw-r--r-- | src/nxt_worker_process.c | 4 |
7 files changed, 36 insertions, 5 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c index 49d785e8..2cd3c921 100644 --- a/src/nxt_application.c +++ b/src/nxt_application.c @@ -382,7 +382,18 @@ nxt_app_http_init(nxt_task_t *task, nxt_runtime_t *rt) void -nxt_port_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) +nxt_app_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) +{ + if (nxt_app->atexit != NULL) { + nxt_app->atexit(task); + } + + nxt_worker_process_quit_handler(task, msg); +} + + +void +nxt_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) { size_t dump_size; nxt_buf_t *b; diff --git a/src/nxt_application.h b/src/nxt_application.h index ce14bc27..b42d77ff 100644 --- a/src/nxt_application.h +++ b/src/nxt_application.h @@ -218,6 +218,7 @@ struct nxt_app_module_s { nxt_int_t (*run)(nxt_task_t *task, nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *wmsg); + void (*atexit)(nxt_task_t *task); }; diff --git a/src/nxt_go.c b/src/nxt_go.c index 207b0deb..329a3cd3 100644 --- a/src/nxt_go.c +++ b/src/nxt_go.c @@ -20,6 +20,7 @@ nxt_application_module_t nxt_go_module = { nxt_string("go"), nxt_go_init, nxt_go_run, + NULL, }; diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index 86b869ed..14427b03 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -179,6 +179,7 @@ NXT_EXPORT nxt_application_module_t nxt_app_module = { nxt_string(PHP_VERSION), nxt_php_init, nxt_php_run, + NULL, }; diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c index 36cd8e14..0f56ea37 100644 --- a/src/nxt_python_wsgi.c +++ b/src/nxt_python_wsgi.c @@ -60,9 +60,9 @@ typedef struct { typedef struct nxt_python_run_ctx_s nxt_python_run_ctx_t; static nxt_int_t nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf); - static nxt_int_t nxt_python_run(nxt_task_t *task, nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *msg); +static void nxt_python_atexit(nxt_task_t *task); static PyObject *nxt_python_create_environ(nxt_task_t *task); static PyObject *nxt_python_get_environ(nxt_task_t *task, @@ -103,6 +103,7 @@ NXT_EXPORT nxt_application_module_t nxt_app_module = { nxt_string(PY_VERSION), nxt_python_init, nxt_python_run, + nxt_python_atexit, }; @@ -455,6 +456,21 @@ fail: } +static void +nxt_python_atexit(nxt_task_t *task) +{ + Py_DECREF(nxt_py_application); + Py_DECREF(nxt_py_start_resp_obj); + Py_DECREF(nxt_py_environ_ptyp); + + Py_Finalize(); + + if (nxt_py_home != NULL) { + nxt_free(nxt_py_home); + } +} + + static PyObject * nxt_python_create_environ(nxt_task_t *task) { diff --git a/src/nxt_runtime.h b/src/nxt_runtime.h index af105c6b..d3e61dc7 100644 --- a/src/nxt_runtime.h +++ b/src/nxt_runtime.h @@ -148,7 +148,8 @@ void nxt_cdecl nxt_log_time_handler(nxt_uint_t level, nxt_log_t *log, void nxt_stream_connection_init(nxt_task_t *task, void *obj, void *data); -void nxt_port_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg); +void nxt_app_quit_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg); +void nxt_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg); #define nxt_runtime_process_each(rt, process) \ diff --git a/src/nxt_worker_process.c b/src/nxt_worker_process.c index c66eb179..17d9e601 100644 --- a/src/nxt_worker_process.c +++ b/src/nxt_worker_process.c @@ -21,11 +21,11 @@ static void nxt_worker_process_sigquit_handler(nxt_task_t *task, void *obj, nxt_port_handlers_t nxt_app_process_port_handlers = { - .quit = nxt_worker_process_quit_handler, + .quit = nxt_app_quit_handler, .new_port = nxt_port_new_port_handler, .change_file = nxt_port_change_log_file_handler, .mmap = nxt_port_mmap_handler, - .data = nxt_port_app_data_handler, + .data = nxt_app_data_handler, .remove_pid = nxt_port_remove_pid_handler, }; |