]> git.kaiwu.me - nginx.git/commitdiff
Fixed removing of listening UNIX sockets when "changing binary".
authorRuslan Ermilov <ru@nginx.com>
Mon, 1 Jun 2020 17:19:27 +0000 (20:19 +0300)
committerRuslan Ermilov <ru@nginx.com>
Mon, 1 Jun 2020 17:19:27 +0000 (20:19 +0300)
When changing binary, sending a SIGTERM to the new binary's master process
should not remove inherited UNIX sockets unless the old binary's master
process has exited.

src/core/nginx.c
src/core/ngx_connection.c
src/core/ngx_cycle.c

index 9fcb0eb2376fd581c6b38d3fae93fb505b0af309..f73e5598e68fb5c25bdad54d67b1ea7923a04129 100644 (file)
@@ -492,6 +492,7 @@ ngx_add_inherited_sockets(ngx_cycle_t *cycle)
             ngx_memzero(ls, sizeof(ngx_listening_t));
 
             ls->fd = (ngx_socket_t) s;
+            ls->inherited = 1;
         }
     }
 
index 33682532aff9b5f0fa2d7118acb62288d11518d6..88fefcea269fdfc50c0ac5a2ea625a8c703651b8 100644 (file)
@@ -1070,7 +1070,8 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle)
 
         if (ls[i].sockaddr->sa_family == AF_UNIX
             && ngx_process <= NGX_PROCESS_MASTER
-            && ngx_new_binary == 0)
+            && ngx_new_binary == 0
+            && (!ls[i].inherited || ngx_getppid() != ngx_parent))
         {
             u_char *name = ls[i].addr_text.data + sizeof("unix:") - 1;
 
index 95f4bdfab501f6b418aaf442139646c3a6e6a69d..764cf46ba6a04931f81b0231e775ecf87117c615 100644 (file)
@@ -520,6 +520,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
                     == NGX_OK)
                 {
                     nls[n].fd = ls[i].fd;
+                    nls[n].inherited = ls[i].inherited;
                     nls[n].previous = &ls[i];
                     ls[i].remain = 1;