From 24905c1a00dbf8f62c902d1b248279c5a31cf199 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Tue, 25 May 2021 18:01:00 +0300 Subject: Fixing racing condition on listen socket close in router (v2). This patch fixes a possible race between the nxt_router_conf_wait() and nxt_router_listen_socket_release() function calls and improves the 7f1b2eaa2d58 commit fix. --- src/nxt_router.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nxt_router.c') diff --git a/src/nxt_router.c b/src/nxt_router.c index 2bbe87b8..c597863e 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -3285,17 +3285,17 @@ nxt_router_listen_socket_close(nxt_task_t *task, void *obj, void *data) joint = lev->socket.data; lev->socket.data = NULL; + /* 'task' refers to lev->task and we cannot use after nxt_free() */ + task = &task->thread->engine->task; + + nxt_router_listen_socket_release(task, joint->socket_conf); + job = joint->close_job; job->work.next = NULL; job->work.handler = nxt_router_conf_wait; nxt_event_engine_post(job->tmcf->engine, &job->work); - /* 'task' refers to lev->task and we cannot use after nxt_free() */ - task = &task->thread->engine->task; - - nxt_router_listen_socket_release(task, joint->socket_conf); - nxt_router_listen_event_release(task, lev, joint); } -- cgit