diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-07-13 21:59:12 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-07-13 21:59:12 +0400 |
commit | a14f89c0683452d573131795e24be2f2fe7580f9 (patch) | |
tree | 47fb65b399898c4076199da74186b51c30fd003a /src/os/unix/ngx_process.c | |
parent | 643c8ea353d4495fb4bbbde1cc7126a37f9a690f (diff) |
nginx-0.0.7-2004-07-13-21:59:12 import
Diffstat (limited to 'src/os/unix/ngx_process.c')
-rw-r--r-- | src/os/unix/ngx_process.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c index d6e2d390d..cd160c233 100644 --- a/src/os/unix/ngx_process.c +++ b/src/os/unix/ngx_process.c @@ -20,7 +20,23 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, ngx_pid_t pid; ngx_int_t s; - s = respawn >= 0 ? respawn : ngx_last_process; + if (respawn >= 0) { + s = respawn; + + } else { + for (s = 0; s < ngx_last_process; s++) { + if (ngx_processes[s].pid == -1) { + break; + } + } + + if (s == NGX_MAX_PROCESSES) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, + "no more than %d processes can be spawned", + NGX_MAX_PROCESSES); + return NGX_ERROR; + } + } if (respawn != NGX_PROCESS_DETACHED) { @@ -146,7 +162,9 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, break; } - ngx_last_process++; + if (s == ngx_last_process) { + ngx_last_process++; + } return pid; } @@ -220,7 +238,7 @@ void ngx_process_get_status() one = 1; - process = ""; + process = "unknown process"; for (i = 0; i < ngx_last_process; i++) { if (ngx_processes[i].pid == pid) { @@ -231,10 +249,6 @@ void ngx_process_get_status() } } - if (i == ngx_last_process) { - process = "unknown process"; - } - if (WTERMSIG(status)) { ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, "%s " PID_T_FMT " exited on signal %d%s", |