diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-01-13 06:39:14 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-01-13 06:39:14 +0000 |
commit | 993dc06b4e39daff4650afea5a7c2d11784d1c78 (patch) | |
tree | e02c5eb591273354592cc0e8284f68e4afa85773 | |
parent | baf61e10d5ef7ad2c57e8f89e7ba5b11e5622c8f (diff) | |
download | nginx-993dc06b4e39daff4650afea5a7c2d11784d1c78.tar.gz nginx-993dc06b4e39daff4650afea5a7c2d11784d1c78.zip |
nginx-0.0.1-2004-01-13-09:39:14 import
-rw-r--r-- | src/core/nginx.c | 49 | ||||
-rw-r--r-- | src/os/unix/ngx_process.c | 3 | ||||
-rw-r--r-- | src/os/unix/ngx_process.h | 3 |
3 files changed, 34 insertions, 21 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 25b1b0873..742aeb89c 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -230,9 +230,10 @@ int main(int argc, char *const *argv, char **envp) static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) { + int signo; ngx_msec_t delay; struct timeval tv; - ngx_uint_t i, live; + ngx_uint_t i, live, first; sigset_t set, wset; delay = 125; @@ -277,6 +278,9 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) for ( ;; ) { + signo = 0; + first = 1; + /* an event loop */ for ( ;; ) { @@ -299,10 +303,6 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "quit cycle"); - if (delay < 15000) { - delay *= 2; - } - if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, "sigprocmask() failed"); @@ -310,8 +310,13 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) } if (ngx_reap == 0) { + + if (delay < 15000) { + delay *= 2; + } + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, - "sleep %d", delay / 1000); + "msleep %d", delay); ngx_msleep(delay); @@ -369,23 +374,20 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) if (ngx_terminate) { if (delay > 10000) { - ngx_signal_processes(cycle, SIGKILL); + signo = SIGKILL; } else { - ngx_signal_processes(cycle, - ngx_signal_value(NGX_TERMINATE_SIGNAL)); + signo = ngx_signal_value(NGX_TERMINATE_SIGNAL); } ngx_process = NGX_PROCESS_QUITING; } if (ngx_quit) { - ngx_signal_processes(cycle, - ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); + signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL); ngx_process = NGX_PROCESS_QUITING; } if (ngx_pause) { - ngx_signal_processes(cycle, - ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); + signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL); ngx_process = NGX_PROCESS_PAUSED; } @@ -402,26 +404,35 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) } if (ngx_reconfigure) { + signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL); ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reconfiguring"); - break; } if (ngx_reopen) { + signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL); ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopening logs"); ngx_reopen_files(cycle); ngx_reopen = 0; } - if (first) { - for (i = 0; i < ngx_last_process; i++) { - if (!ngx_processes[i].detached) { - ngx_processes[i].signal = 1; + if (signo) { + if (first) { + for (i = 0; i < ngx_last_process; i++) { + if (!ngx_processes[i].detached) { + ngx_processes[i].signal = 1; + } } + first = 0; + delay = 125; } - first = 1; + + ngx_signal_processes(cycle, signo); } + if (ngx_reconfigure) { + break; + } } if (ngx_process == NGX_PROCESS_PAUSED) { diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c index 685b0d150..b660d8bec 100644 --- a/src/os/unix/ngx_process.c +++ b/src/os/unix/ngx_process.c @@ -70,6 +70,7 @@ ngx_int_t ngx_spawn_process(ngx_cycle_t *cycle, (respawn == NGX_PROCESS_RESPAWN) ? 1 : 0; ngx_processes[ngx_last_process].detached = (respawn == NGX_PROCESS_DETACHED) ? 1 : 0; + ngx_processes[ngx_last_process].signal = 0; ngx_processes[ngx_last_process].exited = 0; ngx_processes[ngx_last_process].exiting = 0; ngx_last_process++; @@ -118,7 +119,7 @@ void ngx_signal_processes(ngx_cycle_t *cycle, ngx_int_t signo) for (i = 0; i < ngx_last_process; i++) { - if (ngx_processes[i].detached) { + if (!ngx_processes[i].signal) { continue; } diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h index d8727c358..a71f68293 100644 --- a/src/os/unix/ngx_process.h +++ b/src/os/unix/ngx_process.h @@ -16,8 +16,9 @@ typedef struct { unsigned respawn:1; unsigned detached:1; - unsigned exited:1; + unsigned signal:1; unsigned exiting:1; + unsigned exited:1; } ngx_process_t; |