]> git.kaiwu.me - nginx.git/commit
Core: make channel file descriptor errors non-fatal
authorRoman Arutyunyan <arut@nginx.com>
Tue, 18 Aug 2026 16:58:42 +0000 (20:58 +0400)
committerRoman Arutyunyan <arutyunyan.roman@gmail.com>
Tue, 25 Aug 2026 17:33:21 +0000 (21:33 +0400)
commitee03ec42c4dcd21fcbd3c3bd9d804b9d5045fe9d
tree4f078a05e14213ddaf0df1f1ca613669c59a66cc
parenta1f4a617699089204a5e76267941ceee844f19ea
Core: make channel file descriptor errors non-fatal

If a worker process' file descriptor table is full, recvmsg() is not
able to read out the channel fd sent from the master.  This results in
different behavior on different platforms.

On Linux, recvmsg() succeeds, returns the payload and drops the fd.
On BSD systems, the first recvmsg() call fails with EMSGSIZE/EMFILE,
but the next call succeeds and returns the payload without the fd.
On Solaris, recvmsg() fails with EMFILE and drops both the payload
and the fd.

Previously, all of these paths resulted in fatal errors.  The worker
channel was closed and the worker was no longer capable of receiving
messages from the master.  In particular, the NGX_CMD_QUIT command
could not be delivered anymore.  As a result, the worker never exited
after nginx reload and kept running and accepting new connections
forever until killed by a signal.

Fix is to consider those errors non-fatal.  An additional check is
added to the NGX_CMD_CLOSE_CHANNEL handler to make sure the worker
has received a file descriptor for this entry before. Also, the
MSG_CTRUNC check is removed since a proper ancillary data size
validation is now implemented.
src/os/unix/ngx_channel.c
src/os/unix/ngx_process_cycle.c