aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-04-20 07:00:43 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-04-20 07:00:43 +0000
commitbb570859043557c5c1b20d933ff2e4c18d13c980 (patch)
tree3557e525fb733be86acca6932794700ed0ea3c94 /src
parent978dabaf1fdc2c8d190eaae1ff07f5100bf0e245 (diff)
downloadnginx-bb570859043557c5c1b20d933ff2e4c18d13c980.tar.gz
nginx-bb570859043557c5c1b20d933ff2e4c18d13c980.zip
nginx-0.0.3-2004-04-20-11:00:43 import
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_gzip_filter.c4
-rw-r--r--src/os/unix/ngx_errno.h1
-rw-r--r--src/os/unix/ngx_process_cycle.c47
3 files changed, 29 insertions, 23 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index a455fe155..a4b154b74 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -502,7 +502,7 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
ctx->in_hunk = ctx->in->hunk;
ctx->in = ctx->in->next;
- ctx->zstream.next_in = (u_char *) ctx->in_hunk->pos;
+ ctx->zstream.next_in = ctx->in_hunk->pos;
ctx->zstream.avail_in = ctx->in_hunk->last - ctx->in_hunk->pos;
if (ctx->in_hunk->type & NGX_HUNK_LAST) {
@@ -543,7 +543,7 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
break;
}
- ctx->zstream.next_out = (u_char *) ctx->out_hunk->pos;
+ ctx->zstream.next_out = ctx->out_hunk->pos;
ctx->zstream.avail_out = conf->bufs.size;
}
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h
index e7028bb88..375b43d2f 100644
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -9,6 +9,7 @@
typedef int ngx_err_t;
#define NGX_ENOENT ENOENT
+#define NGX_ESRCH ESRCH
#define NGX_EINTR EINTR
#define NGX_ECHILD ECHILD
#define NGX_EACCES EACCES
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index 4240241eb..c1b2a20d3 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -326,6 +326,7 @@ static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
{
ngx_uint_t i;
+ ngx_err_t err;
for (i = 0; i < ngx_last_process; i++) {
@@ -349,9 +350,17 @@ static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
ngx_processes[i].pid, signo);
if (kill(ngx_processes[i].pid, signo) == -1) {
- ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ err = ngx_errno;
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
"kill(%d, %d) failed",
ngx_processes[i].pid, signo);
+
+ if (err == NGX_ESRCH) {
+ ngx_processes[i].exited = 1;
+ ngx_processes[i].exiting = 0;
+ ngx_reap = 1;
+ }
+
continue;
}
@@ -368,6 +377,8 @@ static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exit");
+ ngx_destroy_pool(cycle->pool);
+
exit(0);
}
@@ -375,7 +386,7 @@ static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
sigset_t set;
- ngx_uint_t i;
+ ngx_uint_t i, exiting;
ngx_listening_t *ls;
ngx_core_conf_t *ccf;
#if (NGX_THREADS)
@@ -463,13 +474,22 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
#endif
+ exiting = 0;
+
for ( ;; ) {
+ if (exiting && ngx_event_timer_rbtree == &ngx_event_timer_sentinel) {
+ ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
+ ngx_destroy_pool(cycle->pool);
+ exit(0);
+ }
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
ngx_process_events(cycle);
if (ngx_terminate) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
+ ngx_destroy_pool(cycle->pool);
exit(0);
}
@@ -477,28 +497,13 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
"gracefully shutting down");
ngx_setproctitle("worker process is shutting down");
- break;
- }
-
- if (ngx_reopen) {
- ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");
- ngx_reopen_files(cycle, -1);
- ngx_reopen = 0;
- }
- }
- ngx_close_listening_sockets(cycle);
-
- for ( ;; ) {
- if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) {
- ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
- exit(0);
+ if (!exiting) {
+ ngx_close_listening_sockets(cycle);
+ exiting = 1;
+ }
}
- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
-
- ngx_process_events(cycle);
-
if (ngx_reopen) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");
ngx_reopen_files(cycle, -1);