diff options
author | Max Romanov <max.romanov@nginx.com> | 2021-10-28 17:46:50 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2021-10-28 17:46:50 +0300 |
commit | 86138113eb9a9730dba3073fcb0ff6b242de0e72 (patch) | |
tree | 3c2ae51c41683a5fd2fd45d94d433e6ebb19fce1 | |
parent | 1441f42b5d08a1f7a4b445b10c0adb101edf506d (diff) | |
download | unit-86138113eb9a9730dba3073fcb0ff6b242de0e72.tar.gz unit-86138113eb9a9730dba3073fcb0ff6b242de0e72.tar.bz2 |
Adding explicit app reference to nxt_router_app_port_release().
port->app field is not thread safe and should be used in main thread only.
To release port after request processing, application reference should be
obtained from corresponding request descriptor.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_router.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c index 39d375f8..bbfe3dcf 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -228,8 +228,8 @@ static void nxt_router_app_port_error(nxt_task_t *task, static void nxt_router_app_use(nxt_task_t *task, nxt_app_t *app, int i); static void nxt_router_app_unlink(nxt_task_t *task, nxt_app_t *app); -static void nxt_router_app_port_release(nxt_task_t *task, nxt_port_t *port, - nxt_apr_action_t action); +static void nxt_router_app_port_release(nxt_task_t *task, nxt_app_t *app, + nxt_port_t *port, nxt_apr_action_t action); static void nxt_router_app_port_get(nxt_task_t *task, nxt_app_t *app, nxt_request_rpc_data_t *req_rpc_data); static void nxt_router_http_request_error(nxt_task_t *task, void *obj, @@ -583,14 +583,15 @@ nxt_request_rpc_data_unlink(nxt_task_t *task, nxt_router_msg_cancel(task, req_rpc_data); + app = req_rpc_data->app; + if (req_rpc_data->app_port != NULL) { - nxt_router_app_port_release(task, req_rpc_data->app_port, + nxt_router_app_port_release(task, app, req_rpc_data->app_port, req_rpc_data->apr_action); req_rpc_data->app_port = NULL; } - app = req_rpc_data->app; r = req_rpc_data->request; if (r != NULL) { @@ -4211,7 +4212,7 @@ nxt_router_response_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg, nxt_thread_mutex_unlock(&app->mutex); - nxt_router_app_port_release(task, app_port, NXT_APR_UPGRADE); + nxt_router_app_port_release(task, app, app_port, NXT_APR_UPGRADE); req_rpc_data->apr_action = NXT_APR_CLOSE; nxt_debug(task, "stream #%uD upgrade", req_rpc_data->stream); @@ -4493,7 +4494,7 @@ nxt_router_app_port_ready(nxt_task_t *task, nxt_port_recv_msg_t *msg, nxt_router_app_shared_port_send(task, port); - nxt_router_app_port_release(task, port, NXT_APR_NEW_PORT); + nxt_router_app_port_release(task, app, port, NXT_APR_NEW_PORT); } @@ -4670,19 +4671,15 @@ nxt_router_app_unlink(nxt_task_t *task, nxt_app_t *app) static void -nxt_router_app_port_release(nxt_task_t *task, nxt_port_t *port, +nxt_router_app_port_release(nxt_task_t *task, nxt_app_t *app, nxt_port_t *port, nxt_apr_action_t action) { int inc_use; uint32_t got_response, dec_requests; - nxt_app_t *app; nxt_bool_t port_unchained, send_quit, adjust_idle_timer; nxt_port_t *main_app_port; nxt_assert(port != NULL); - nxt_assert(port->app != NULL); - - app = port->app; inc_use = 0; got_response = 0; |