From 8f0192bb4cd953b7e8ca0f82f789a21fc5745220 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 9 Mar 2023 23:26:56 +0000 Subject: Remove some dormant code from nxt_process_quit(). In nxt_process_quit() there is a loop that iterates over the task->thread->runtime->listen_sockets array and closes the connections. This code has been there from the beginning $ git log --pretty=oneline -S'if (rt->listen_sockets != NULL)' e9e5ddd5a5d9ce99768833137eac2551a710becf Refactor of process management. 6f2c9acd1841ca20a1388b34aef64e9f00459090 Processes refactoring. The cycle has been renamed to the runtime. $ git log --pretty=oneline -S'if (cycle->listen_sockets != NULL) {' 6f2c9acd1841ca20a1388b34aef64e9f00459090 Processes refactoring. The cycle has been renamed to the runtime. 16cbf3c076a0aca6d47adaf3f719493674cf2363 Initial version. but never seems to have been used (AFAICT and certainly not recently, confirmed by code inspection and running pytests with a bunch of language modules enabled and the code in question was never executed) as the listen_sockets array has never been populated... until now. The previous commit now adds Unix domain sockets to this array so that they can be unlink(2)'d upon exit and reconfiguration. This has now caused this dormant code to become active as it now tries to close these sockets (from at least the prototype processes), this array is inherited via fork by other processes. The file descriptor for these sockets is set to -1 when they are put into this array. This then results in close(-1) calls which caused multiple failures in the pytests such as > assert not alerts, 'alert(s)' E AssertionError: alert(s) E assert not ['2023/03/09 23:26:14 [alert] 137673#137673 socket close(-1) failed (9: Bad file descriptor)'] I think the simplest thing is to just remove this code. Reviewed-by: Alejandro Colomar Signed-off-by: Andrew Clayton --- src/nxt_process.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/nxt_process.c b/src/nxt_process.c index 025efe70..c7f10769 100644 --- a/src/nxt_process.c +++ b/src/nxt_process.c @@ -1251,14 +1251,9 @@ nxt_process_close_ports(nxt_task_t *task, nxt_process_t *process) void nxt_process_quit(nxt_task_t *task, nxt_uint_t exit_status) { - nxt_uint_t n; nxt_queue_t *listen; - nxt_runtime_t *rt; nxt_queue_link_t *link, *next; nxt_listen_event_t *lev; - nxt_listen_socket_t *ls; - - rt = task->thread->runtime; nxt_debug(task, "close listen connections"); @@ -1275,21 +1270,5 @@ nxt_process_quit(nxt_task_t *task, nxt_uint_t exit_status) nxt_fd_event_close(task->thread->engine, &lev->socket); } - if (rt->listen_sockets != NULL) { - - ls = rt->listen_sockets->elts; - n = rt->listen_sockets->nelts; - - while (n != 0) { - nxt_socket_close(task, ls->socket); - ls->socket = -1; - - ls++; - n--; - } - - rt->listen_sockets->nelts = 0; - } - nxt_runtime_quit(task, exit_status); } -- cgit