]> git.kaiwu.me - nginx.git/commitdiff
Core: delete accept timer on worker shutdown
authorRoman Arutyunyan <arut@nginx.com>
Thu, 20 Aug 2026 12:53:42 +0000 (16:53 +0400)
committerRoman Arutyunyan <arutyunyan.roman@gmail.com>
Tue, 25 Aug 2026 17:33:21 +0000 (21:33 +0400)
Previously, when the worker file descriptor table was full, a listen
connection might be disabled and a timeout might be set for re-enabling
it.  If during this period the worker received the NGX_CMD_QUIT signal,
the accept connection would be recycled, but the timer would remain set.
On timer expiration, an attempt to accept a new connection would result
in "accept4() failed (9: Bad file descriptor)" alert because c->fd was
reset to -1.

Fix is to delete accept timer when closing listen connections.

src/core/ngx_connection.c

index 33b9b1607772a53db7a2789a2c9602c9ccbc7d31..7ea7706e55dbaaa8bc9ea24c6f1fb830f344fd46 100644 (file)
@@ -1166,6 +1166,10 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle)
                 }
             }
 
+            if (c->read->timer_set) {
+                ngx_del_timer(c->read);
+            }
+
             ngx_free_connection(c);
 
             c->fd = (ngx_socket_t) -1;