[nginx] Master process: make sure unix domain sockets are removed from disk when performing graceful shutdown.

Datong Sun dndx at idndx.com
Fri Dec 2 09:20:25 UTC 2016


# HG changeset patch
# User Datong Sun <dndx at idndx.com>
# Date 1480669608 21600
#      Fri Dec 02 03:06:48 2016 -0600
# Node ID 1b7a6785d1f3c76f436a9dea5cb0fc86e1db5f2b
# Parent  75dbab4ea930bc73cca98d183c2f556eb5125462
Master process: make sure unix domain sockets are removed from
disk when performing graceful shutdown by using
ngx_close_listening_sockets() to close them.

This fixes https://trac.nginx.org/nginx/ticket/753

diff -r 75dbab4ea930 -r 1b7a6785d1f3 src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c Mon Nov 21 16:03:42 2016 +0300
+++ b/src/os/unix/ngx_process_cycle.c Fri Dec 02 03:06:48 2016 -0600
@@ -76,12 +76,11 @@
     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);
@@ -203,16 +202,7 @@
         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;
         }

-- 
Datong Sun
dndx at idndx.com



More information about the nginx-devel mailing list