Fixed removing of listening UNIX sockets when "changing binary". 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.
diff --git a/src/core/nginx.c b/src/core/nginx.c index 9fcb0eb..f73e559 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c
@@ -492,6 +492,7 @@ ngx_memzero(ls, sizeof(ngx_listening_t)); ls->fd = (ngx_socket_t) s; + ls->inherited = 1; } }
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 3368253..88fefce 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c
@@ -1070,7 +1070,8 @@ 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;
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 95f4bdf..764cf46 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c
@@ -520,6 +520,7 @@ == NGX_OK) { nls[n].fd = ls[i].fd; + nls[n].inherited = ls[i].inherited; nls[n].previous = &ls[i]; ls[i].remain = 1;