diff src/os/unix/ngx_process_cycle.c @ 122:d25a1d6034f1 NGINX_0_3_8

nginx 0.3.8 *) Security: nginx now checks URI got from a backend in "X-Accel-Redirect" header line or in SSI file for the "/../" paths and zeroes. *) Change: nginx now does not treat the empty user name in the "Authorization" header line as valid one. *) Feature: the "ssl_session_timeout" directives of the ngx_http_ssl_module and ngx_imap_ssl_module. *) Feature: the "auth_http_header" directive of the ngx_imap_auth_http_module. *) Feature: the "add_header" directive. *) Feature: the ngx_http_realip_module. *) Feature: the new variables to use in the "log_format" directive: $bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri, $request_time, $request_length, $upstream_status, $upstream_response_time, $gzip_ratio, $uid_got, $uid_set, $connection, $pipe, and $msec. The parameters in the "%name" form will be canceled soon. *) Change: now the false variable values in the "if" directive are the empty string "" and string starting with "0". *) Bugfix: while using proxied or FastCGI-server nginx may leave connections and temporary files with client requests in open state. *) Bugfix: the worker processes did not flush the buffered logs on graceful exit. *) Bugfix: if the request URI was changes by the "rewrite" directive and the request was proxied in location given by regular expression, then the incorrect request was transferred to backend; bug appeared in 0.2.6. *) Bugfix: the "expires" directive did not remove the previous "Expires" header. *) Bugfix: nginx may stop to accept requests if the "rtsig" method and several worker processes were used. *) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in SSI commands. *) Bugfix: if the response was ended just after the SSI command and gzipping was used, then the response did not transferred complete or did not transferred at all.
author Igor Sysoev <http://sysoev.ru>
date Wed, 09 Nov 2005 00:00:00 +0300
parents e85dca77c46a
children df17fbafec8f
line wrap: on
line diff
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -15,9 +15,10 @@ static void ngx_start_worker_processes(n
 static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
 static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle);
-static void ngx_master_exit(ngx_cycle_t *cycle);
+static void ngx_master_process_exit(ngx_cycle_t *cycle);
 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
+static void ngx_worker_process_exit(ngx_cycle_t *cycle);
 static void ngx_channel_handler(ngx_event_t *ev);
 #if (NGX_THREADS)
 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
@@ -156,7 +157,7 @@ ngx_master_process_cycle(ngx_cycle_t *cy
         }
 
         if (!live && (ngx_terminate || ngx_quit)) {
-            ngx_master_exit(cycle);
+            ngx_master_process_exit(cycle);
         }
 
         if (ngx_terminate) {
@@ -283,7 +284,7 @@ ngx_single_process_cycle(ngx_cycle_t *cy
                 }
             }
 
-            ngx_master_exit(cycle);
+            ngx_master_process_exit(cycle);
         }
 
         if (ngx_reconfigure) {
@@ -628,7 +629,7 @@ ngx_reap_childs(ngx_cycle_t *cycle)
 
 
 static void
-ngx_master_exit(ngx_cycle_t *cycle)
+ngx_master_process_exit(ngx_cycle_t *cycle)
 {
     ngx_uint_t  i;
 
@@ -658,8 +659,6 @@ ngx_master_exit(ngx_cycle_t *cycle)
 static void
 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
 {
-    ngx_uint_t         i;
-    ngx_connection_t  *c;
 #if (NGX_THREADS)
     ngx_int_t          n;
     ngx_err_t          err;
@@ -717,26 +716,7 @@ ngx_worker_process_cycle(ngx_cycle_t *cy
         {
             ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
 
-
-#if (NGX_THREADS)
-            ngx_terminate = 1;
-
-            ngx_wakeup_worker_threads(cycle);
-#endif
-
-            if (ngx_debug_quit) {
-                ngx_debug_point();
-            }
-
-            /*
-             * we do not destroy cycle->pool here because a signal handler
-             * that uses cycle->log can be called at this point
-             */
-
-#if 0
-            ngx_destroy_pool(cycle->pool);
-#endif
-            exit(0);
+            ngx_worker_process_exit(cycle);
         }
 
         ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
@@ -746,41 +726,7 @@ ngx_worker_process_cycle(ngx_cycle_t *cy
         if (ngx_terminate) {
             ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
 
-#if (NGX_THREADS)
-            ngx_wakeup_worker_threads(cycle);
-#endif
-
-            for (i = 0; ngx_modules[i]; i++) {
-                if (ngx_modules[i]->exit_process) {
-                    ngx_modules[i]->exit_process(cycle);
-                }
-            }
-
-            c = cycle->connections;
-            for (i = 0; i < cycle->connection_n; i++) {
-                if (c[i].fd != -1
-                    && c[i].read
-                    && !c[i].read->accept
-                    && !c[i].read->channel)
-                {
-                    ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
-                                  "open socket #%d left in %ui connection, "
-                                  "aborting",
-                                  c[i].fd, i);
-                    ngx_abort();
-                }
-            }
-
-            /*
-             * we do not destroy cycle->pool here because a signal handler
-             * that uses cycle->log can be called at this point
-             */
-
-#if 0
-            ngx_destroy_pool(cycle->pool);
-#endif
-
-            exit(0);
+            ngx_worker_process_exit(cycle);
         }
 
         if (ngx_quit) {
@@ -957,6 +903,56 @@ ngx_worker_process_init(ngx_cycle_t *cyc
 
 
 static void
+ngx_worker_process_exit(ngx_cycle_t *cycle)
+{
+    ngx_uint_t         i;
+    ngx_connection_t  *c;
+
+#if (NGX_THREADS)
+    ngx_terminate = 1;
+
+    ngx_wakeup_worker_threads(cycle);
+#endif
+
+    for (i = 0; ngx_modules[i]; i++) {
+        if (ngx_modules[i]->exit_process) {
+            ngx_modules[i]->exit_process(cycle);
+        }
+    }
+
+    c = cycle->connections;
+    for (i = 0; i < cycle->connection_n; i++) {
+        if (c[i].fd != -1
+            && c[i].read
+            && !c[i].read->accept
+            && !c[i].read->channel)
+        {
+            ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
+                          "open socket #%d left in %ui connection, "
+                          "aborting",
+                          c[i].fd, i);
+            ngx_abort();
+        }
+    }
+
+    if (ngx_debug_quit) {
+        ngx_debug_point();
+    }
+
+    /*
+     * we do not destroy cycle->pool here because a signal handler
+     * that uses cycle->log can be called at this point
+     */
+
+#if 0
+    ngx_destroy_pool(cycle->pool);
+#endif
+
+    exit(0);
+}
+
+
+static void
 ngx_channel_handler(ngx_event_t *ev)
 {
     ngx_int_t          n;