[nginx] Core: when changing binary, newly forked master process should not remove unix domain socket unless old master has quit.

Datong Sun dndx at idndx.com
Fri Dec 2 09:23:36 UTC 2016


# HG changeset patch
# User Datong Sun <dndx at idndx.com>
# Date 1480669905 21600
#      Fri Dec 02 03:11:45 2016 -0600
# Node ID 92a7853a439708584bbc45b416df464c64ec446e
# Parent  1b7a6785d1f3c76f436a9dea5cb0fc86e1db5f2b
Core: when changing binary, newly forked master process should
not remove unix domain socket unless old master has quit.

This commit fixes a bug that during a binary change, when both
old and new master processes are running, sending TERM to the
new master process will accidently remove unix domain socket
from disk while old master is still listening on it.

diff -r 1b7a6785d1f3 -r 92a7853a4397 src/core/ngx_connection.c
--- a/src/core/ngx_connection.c Fri Dec 02 03:06:48 2016 -0600
+++ b/src/core/ngx_connection.c Fri Dec 02 03:11:45 2016 -0600
@@ -1007,7 +1007,8 @@

         if (ls[i].sockaddr->sa_family == AF_UNIX
             && ngx_process <= NGX_PROCESS_MASTER
-            && ngx_new_binary == 0)
+            && ngx_new_binary == 0
+            && getppid() == 1)
         {
             u_char *name = ls[i].addr_text.data + sizeof("unix:") - 1;

-- 
Datong Sun
dndx at idndx.com



More information about the nginx-devel mailing list