nginx-0.0.3-2004-04-20-11:00:43 import

This commit is contained in:
Igor Sysoev 2004-04-20 07:00:43 +00:00
parent 978dabaf1f
commit bb57085904
3 changed files with 30 additions and 24 deletions

View File

@ -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_hunk = ctx->in->hunk;
ctx->in = ctx->in->next; 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; ctx->zstream.avail_in = ctx->in_hunk->last - ctx->in_hunk->pos;
if (ctx->in_hunk->type & NGX_HUNK_LAST) { 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; 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; ctx->zstream.avail_out = conf->bufs.size;
} }

View File

@ -9,6 +9,7 @@
typedef int ngx_err_t; typedef int ngx_err_t;
#define NGX_ENOENT ENOENT #define NGX_ENOENT ENOENT
#define NGX_ESRCH ESRCH
#define NGX_EINTR EINTR #define NGX_EINTR EINTR
#define NGX_ECHILD ECHILD #define NGX_ECHILD ECHILD
#define NGX_EACCES EACCES #define NGX_EACCES EACCES

View File

@ -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) static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
{ {
ngx_uint_t i; ngx_uint_t i;
ngx_err_t err;
for (i = 0; i < ngx_last_process; i++) { 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); ngx_processes[i].pid, signo);
if (kill(ngx_processes[i].pid, signo) == -1) { 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", "kill(%d, %d) failed",
ngx_processes[i].pid, signo); ngx_processes[i].pid, signo);
if (err == NGX_ESRCH) {
ngx_processes[i].exited = 1;
ngx_processes[i].exiting = 0;
ngx_reap = 1;
}
continue; 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_log_error(NGX_LOG_INFO, cycle->log, 0, "exit");
ngx_destroy_pool(cycle->pool);
exit(0); 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) static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{ {
sigset_t set; sigset_t set;
ngx_uint_t i; ngx_uint_t i, exiting;
ngx_listening_t *ls; ngx_listening_t *ls;
ngx_core_conf_t *ccf; ngx_core_conf_t *ccf;
#if (NGX_THREADS) #if (NGX_THREADS)
@ -463,13 +474,22 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
#endif #endif
exiting = 0;
for ( ;; ) { 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_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
ngx_process_events(cycle); ngx_process_events(cycle);
if (ngx_terminate) { if (ngx_terminate) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting"); ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
ngx_destroy_pool(cycle->pool);
exit(0); exit(0);
} }
@ -477,27 +497,12 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
"gracefully shutting down"); "gracefully shutting down");
ngx_setproctitle("worker process is 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;
}
}
if (!exiting) {
ngx_close_listening_sockets(cycle); ngx_close_listening_sockets(cycle);
exiting = 1;
for ( ;; ) { }
if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
exit(0);
} }
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
ngx_process_events(cycle);
if (ngx_reopen) { if (ngx_reopen) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs"); ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");