]> git.kaiwu.me - nginx.git/commitdiff
Control API: log errors from accepted socket setup
authorOskar Eichler <62393985+OskarEichler@users.noreply.github.com>
Fri, 4 Sep 2026 15:52:07 +0000 (22:52 +0700)
committerAleksei Bavshin <a.bavshin@f5.com>
Thu, 15 Oct 2026 15:07:43 +0000 (08:07 -0700)
Accepted control connections discarded errno when setting close-on-exec,
nonblocking I/O, or signal ownership. The error log identified the failed
fcntl() operation but omitted the operating system reason.

Pass ngx_socket_errno to the three error logs, consistently with listener
setup and inherited socket handling.

src/os/unix/ngx_control.c

index 08b2d0195acc341537ad543548e20c516d199487..f191f00ddd8988ff3b1e1199c7e45aec6be4c10c 100644 (file)
@@ -493,21 +493,21 @@ ngx_control_handle_accept(void)
                        "control accept fd:%d", r->fd);
 
         if (fcntl(r->fd, F_SETFD, FD_CLOEXEC) == -1) {
-            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0,
+            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_socket_errno,
                           "control: fcntl(FD_CLOEXEC) failed");
             ngx_close_socket(r->fd);
             continue;
         }
 
         if (fcntl(r->fd, F_SETFL, O_ASYNC|O_NONBLOCK) == -1) {
-            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0,
+            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_socket_errno,
                           "control: fcntl(O_ASYNC|O_NONBLOCK) failed");
             ngx_close_socket(r->fd);
             continue;
         }
 
         if (fcntl(r->fd, F_SETOWN, ngx_pid) == -1) {
-            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0,
+            ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_socket_errno,
                           "control: fcntl(F_SETOWN) failed");
             ngx_close_socket(r->fd);
             continue;