[nginx] Core: when changing binary, newly forked master process should not remove unix domain socket unless old master has quit.
mdounin at mdounin.ru
Wed Dec 7 15:47:39 UTC 2016
On Fri, Dec 02, 2016 at 01:23:36AM -0800, Datong Sun via nginx-devel wrote:
> # 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.
Style, please keep summary line under 67 symbols. See
http://nginx.org/en/docs/contributing_changes.html for more
> 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;
The getppid() call doesn't look right in platform-independent
code. Especially keeping in mind that the test in question known
to produce incorrect results in some cases - at least in Solaris
zones, and AFAIR somehow with systemd.
Also note that with your previous patch this problem starts to
affect not only TERM, but also QUIT.
More information about the nginx-devel