diff src/os/unix/ngx_process_cycle.c @ 302:1526e7686b20

nginx-0.0.3-2004-04-01-10:21:13 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 01 Apr 2004 06:21:13 +0000
parents 744965ec6275
children 00c5660d2707
line wrap: on
line diff
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -65,10 +65,11 @@ void ngx_master_process_cycle(ngx_cycle_
     signo = 0;
     live = 0;
 
-    ngx_accept_mutex = mmap(NULL, sizeof(ngx_atomic_t), PROT_READ|PROT_WRITE,
-                            MAP_ANON|MAP_SHARED, -1, 0);
+    ngx_accept_mutex_ptr = mmap(NULL, sizeof(ngx_atomic_t),
+                                PROT_READ|PROT_WRITE,
+                                MAP_ANON|MAP_SHARED, -1, 0);
 
-    if (ngx_accept_mutex == NULL) {
+    if (ngx_accept_mutex_ptr == NULL) {
         ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
                       "mmap(MAP_ANON|MAP_SHARED) failed");
         /* fatal */
@@ -375,12 +376,13 @@ static void ngx_worker_process_cycle(ngx
     ngx_process = NGX_PROCESS_WORKER;
     ngx_last_process = 0;
 
-    if (ngx_accept_mutex) {
-        ngx_accept_token = 1;
+    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
+
+    if (ccf->worker_processes > 1) {
+        ngx_accept_mutex = ngx_accept_mutex_ptr;
+        ngx_accept_mutex_held = 1;
     }
 
-    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
-
     if (ccf->group != (gid_t) NGX_CONF_UNSET) {
         if (setuid(ccf->group) == -1) {
             ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
@@ -483,6 +485,8 @@ static void ngx_worker_process_cycle(ngx
 
     ngx_close_listening_sockets(cycle);
 
+    ngx_accept_mutex = NULL;
+
     for ( ;; ) {
         if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) {
             ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");