aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_process_cycle.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-03-31 15:26:46 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-03-31 15:26:46 +0000
commit709405b7559d3abcb90b61368c7072fb774f661b (patch)
treeb6603153b1f77014711eff77d0d280d078d233cc /src/os/unix/ngx_process_cycle.c
parenta741f8d0216d95a7ee0fbb8a24947de8842900c0 (diff)
downloadnginx-709405b7559d3abcb90b61368c7072fb774f661b.tar.gz
nginx-709405b7559d3abcb90b61368c7072fb774f661b.zip
nginx-0.0.3-2004-03-31-19:26:46 import
Diffstat (limited to 'src/os/unix/ngx_process_cycle.c')
-rw-r--r--src/os/unix/ngx_process_cycle.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index cc3d8a4c4..f2d392a91 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -65,12 +65,26 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
signo = 0;
live = 0;
+ ngx_accept_mutex = mmap(NULL, sizeof(ngx_atomic_t), PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_SHARED, -1, 0);
+
+ if (ngx_accept_mutex == NULL) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
+ "mmap(MAP_ANON|MAP_SHARED) failed");
+ /* fatal */
+ exit(2);
+ }
+
for ( ;; ) {
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "new cycle");
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
ngx_core_module);
+ if (ccf->worker_processes == NGX_CONF_UNSET) {
+ ccf->worker_processes = 1;
+ }
+
if (ngx_process == NGX_PROCESS_MASTER) {
for (i = 0; i < (ngx_uint_t) ccf->worker_processes; i++) {
ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
@@ -150,7 +164,7 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"worker cycle");
- ngx_process_events(cycle->log);
+ ngx_process_events(cycle);
live = 0;
}
@@ -361,6 +375,10 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
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->group != (gid_t) NGX_CONF_UNSET) {
@@ -442,7 +460,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
for ( ;; ) {
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
- ngx_process_events(cycle->log);
+ ngx_process_events(cycle);
if (ngx_terminate) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
@@ -473,7 +491,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
- ngx_process_events(cycle->log);
+ ngx_process_events(cycle);
if (ngx_reopen) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");