Welcome! Log In Create A New Profile

Advanced

[nginx] Fixed removing of listening UNIX sockets when "changing binary".

June 01, 2020 03:34PM
details: https://hg.nginx.org/nginx/rev/9c038f5e0464
branches:
changeset: 7662:9c038f5e0464
user: Ruslan Ermilov <ru@nginx.com>
date: Mon Jun 01 20:19:27 2020 +0300
description:
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.

diffstat:

src/core/nginx.c | 1 +
src/core/ngx_connection.c | 3 ++-
src/core/ngx_cycle.c | 1 +
3 files changed, 4 insertions(+), 1 deletions(-)

diffs (35 lines):

diff -r 8cadaf7e7231 -r 9c038f5e0464 src/core/nginx.c
--- a/src/core/nginx.c Tue May 26 19:17:11 2020 +0300
+++ b/src/core/nginx.c Mon Jun 01 20:19:27 2020 +0300
@@ -492,6 +492,7 @@ ngx_add_inherited_sockets(ngx_cycle_t *c
ngx_memzero(ls, sizeof(ngx_listening_t));

ls->fd = (ngx_socket_t) s;
+ ls->inherited = 1;
}
}

diff -r 8cadaf7e7231 -r 9c038f5e0464 src/core/ngx_connection.c
--- a/src/core/ngx_connection.c Tue May 26 19:17:11 2020 +0300
+++ b/src/core/ngx_connection.c Mon Jun 01 20:19:27 2020 +0300
@@ -1070,7 +1070,8 @@ ngx_close_listening_sockets(ngx_cycle_t

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 -r 8cadaf7e7231 -r 9c038f5e0464 src/core/ngx_cycle.c
--- a/src/core/ngx_cycle.c Tue May 26 19:17:11 2020 +0300
+++ b/src/core/ngx_cycle.c Mon Jun 01 20:19:27 2020 +0300
@@ -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;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Fixed removing of listening UNIX sockets when "changing binary".

ru@nginx.com 485 June 01, 2020 03:34PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 202
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready