[nginx] Fixed SIGQUIT not removing listening UNIX sockets (closes #753).

Ruslan Ermilov ru at nginx.com
Mon Jun 1 19:33:07 UTC 2020


details:   https://hg.nginx.org/nginx/rev/7cbf6389194b
branches:  
changeset: 7663:7cbf6389194b
user:      Ruslan Ermilov <ru at nginx.com>
date:      Mon Jun 01 22:31:23 2020 +0300
description:
Fixed SIGQUIT not removing listening UNIX sockets (closes #753).

Listening UNIX sockets were not removed on graceful shutdown, preventing
the next runs.  The fix is to replace the custom socket closing code in
ngx_master_process_cycle() by the ngx_close_listening_sockets() call.

diffstat:

 src/os/unix/ngx_process_cycle.c |  14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diffs (35 lines):

diff -r 9c038f5e0464 -r 7cbf6389194b src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c	Mon Jun 01 20:19:27 2020 +0300
+++ b/src/os/unix/ngx_process_cycle.c	Mon Jun 01 22:31:23 2020 +0300
@@ -77,12 +77,11 @@ ngx_master_process_cycle(ngx_cycle_t *cy
     u_char            *p;
     size_t             size;
     ngx_int_t          i;
-    ngx_uint_t         n, sigio;
+    ngx_uint_t         sigio;
     sigset_t           set;
     struct itimerval   itv;
     ngx_uint_t         live;
     ngx_msec_t         delay;
-    ngx_listening_t   *ls;
     ngx_core_conf_t   *ccf;
 
     sigemptyset(&set);
@@ -204,16 +203,7 @@ ngx_master_process_cycle(ngx_cycle_t *cy
         if (ngx_quit) {
             ngx_signal_worker_processes(cycle,
                                         ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
-
-            ls = cycle->listening.elts;
-            for (n = 0; n < cycle->listening.nelts; n++) {
-                if (ngx_close_socket(ls[n].fd) == -1) {
-                    ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
-                                  ngx_close_socket_n " %V failed",
-                                  &ls[n].addr_text);
-                }
-            }
-            cycle->listening.nelts = 0;
+            ngx_close_listening_sockets(cycle);
 
             continue;
         }


More information about the nginx-devel mailing list