summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix/ngx_process_cycle.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-02-01 15:49:36 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-02-01 15:49:36 +0000
commitc419414db440c298006d814936de28964d654b38 (patch)
tree3d86adc0fd3c6aa0c41633d4f95eea6b5d8f263b /src/os/unix/ngx_process_cycle.c
parent95a5ecb1ac78b14b759ada666b2114783fc1c2d2 (diff)
downloadnginx-c419414db440c298006d814936de28964d654b38.tar.gz
nginx-c419414db440c298006d814936de28964d654b38.tar.bz2
merge r3294, r3305:
Fix a bug introduced in r2032: After a child process has read a terminate message from a channel, the process tries to read the channel again. The kernel (at least FreeBSD) may preempt the process and sends a SIGIO signal to a master process. The master process sends a new terminate message, the kernel switches again to the the child process, and the child process reads the messages instead of an EAGAIN error. And this may repeat over and over. Being that the child process can not exit the cycle and test the termination flag set by the message handler. The fix disallow the master process to send a new terminate message on SIGIO signal reception. It may send the message only on SIGALARM signal.
Diffstat (limited to 'src/os/unix/ngx_process_cycle.c')
-rw-r--r--src/os/unix/ngx_process_cycle.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index 69db458f5..e3b054834 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -86,7 +86,7 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
u_char *p;
size_t size;
ngx_int_t i;
- ngx_uint_t n;
+ ngx_uint_t n, sigio;
sigset_t set;
struct itimerval itv;
ngx_uint_t live;
@@ -139,11 +139,13 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_new_binary = 0;
delay = 0;
+ sigio = 0;
live = 1;
for ( ;; ) {
if (delay) {
if (ngx_sigalrm) {
+ sigio = 0;
delay *= 2;
ngx_sigalrm = 0;
}
@@ -168,7 +170,8 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_time_update(0, 0);
- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "wake up");
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
+ "wake up, sigio %i", sigio);
if (ngx_reap) {
ngx_reap = 0;
@@ -186,6 +189,13 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
delay = 50;
}
+ if (sigio) {
+ sigio--;
+ continue;
+ }
+
+ sigio = ccf->worker_processes + 2 /* cache processes */;
+
if (delay > 1000) {
ngx_signal_worker_processes(cycle, SIGKILL);
} else {