mirror of
https://github.com/nginx/nginx.git
synced 2025-06-13 06:12:44 +08:00
nginx-0.0.1-2004-01-13-09:39:14 import
This commit is contained in:
parent
baf61e10d5
commit
993dc06b4e
@ -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)
|
static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
|
int signo;
|
||||||
ngx_msec_t delay;
|
ngx_msec_t delay;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
ngx_uint_t i, live;
|
ngx_uint_t i, live, first;
|
||||||
sigset_t set, wset;
|
sigset_t set, wset;
|
||||||
|
|
||||||
delay = 125;
|
delay = 125;
|
||||||
@ -277,6 +278,9 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
|
|
||||||
|
signo = 0;
|
||||||
|
first = 1;
|
||||||
|
|
||||||
/* an event loop */
|
/* an event loop */
|
||||||
|
|
||||||
for ( ;; ) {
|
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,
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
"quit cycle");
|
"quit cycle");
|
||||||
|
|
||||||
if (delay < 15000) {
|
|
||||||
delay *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1) {
|
if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
"sigprocmask() failed");
|
"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 (ngx_reap == 0) {
|
||||||
|
|
||||||
|
if (delay < 15000) {
|
||||||
|
delay *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
"sleep %d", delay / 1000);
|
"msleep %d", delay);
|
||||||
|
|
||||||
ngx_msleep(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 (ngx_terminate) {
|
||||||
if (delay > 10000) {
|
if (delay > 10000) {
|
||||||
ngx_signal_processes(cycle, SIGKILL);
|
signo = SIGKILL;
|
||||||
} else {
|
} else {
|
||||||
ngx_signal_processes(cycle,
|
signo = ngx_signal_value(NGX_TERMINATE_SIGNAL);
|
||||||
ngx_signal_value(NGX_TERMINATE_SIGNAL));
|
|
||||||
}
|
}
|
||||||
ngx_process = NGX_PROCESS_QUITING;
|
ngx_process = NGX_PROCESS_QUITING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_quit) {
|
if (ngx_quit) {
|
||||||
ngx_signal_processes(cycle,
|
signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
|
||||||
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
|
|
||||||
ngx_process = NGX_PROCESS_QUITING;
|
ngx_process = NGX_PROCESS_QUITING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_pause) {
|
if (ngx_pause) {
|
||||||
ngx_signal_processes(cycle,
|
signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
|
||||||
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
|
|
||||||
ngx_process = NGX_PROCESS_PAUSED;
|
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) {
|
if (ngx_reconfigure) {
|
||||||
|
signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
|
||||||
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reconfiguring");
|
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reconfiguring");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_reopen) {
|
if (ngx_reopen) {
|
||||||
|
signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
|
||||||
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
|
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
|
||||||
"reopening logs");
|
"reopening logs");
|
||||||
ngx_reopen_files(cycle);
|
ngx_reopen_files(cycle);
|
||||||
ngx_reopen = 0;
|
ngx_reopen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first) {
|
if (signo) {
|
||||||
for (i = 0; i < ngx_last_process; i++) {
|
if (first) {
|
||||||
if (!ngx_processes[i].detached) {
|
for (i = 0; i < ngx_last_process; i++) {
|
||||||
ngx_processes[i].signal = 1;
|
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) {
|
if (ngx_process == NGX_PROCESS_PAUSED) {
|
||||||
|
@ -70,6 +70,7 @@ ngx_int_t ngx_spawn_process(ngx_cycle_t *cycle,
|
|||||||
(respawn == NGX_PROCESS_RESPAWN) ? 1 : 0;
|
(respawn == NGX_PROCESS_RESPAWN) ? 1 : 0;
|
||||||
ngx_processes[ngx_last_process].detached =
|
ngx_processes[ngx_last_process].detached =
|
||||||
(respawn == NGX_PROCESS_DETACHED) ? 1 : 0;
|
(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].exited = 0;
|
||||||
ngx_processes[ngx_last_process].exiting = 0;
|
ngx_processes[ngx_last_process].exiting = 0;
|
||||||
ngx_last_process++;
|
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++) {
|
for (i = 0; i < ngx_last_process; i++) {
|
||||||
|
|
||||||
if (ngx_processes[i].detached) {
|
if (!ngx_processes[i].signal) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,9 @@ typedef struct {
|
|||||||
|
|
||||||
unsigned respawn:1;
|
unsigned respawn:1;
|
||||||
unsigned detached:1;
|
unsigned detached:1;
|
||||||
unsigned exited:1;
|
unsigned signal:1;
|
||||||
unsigned exiting:1;
|
unsigned exiting:1;
|
||||||
|
unsigned exited:1;
|
||||||
} ngx_process_t;
|
} ngx_process_t;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user