2004-03-04 15:04:55 +08:00
|
|
|
|
2004-09-28 16:34:51 +08:00
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_event.h>
|
2004-06-23 23:18:17 +08:00
|
|
|
#include <ngx_channel.h>
|
2004-04-10 00:03:04 +08:00
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
|
2005-03-19 20:38:37 +08:00
|
|
|
ngx_int_t type);
|
2004-11-21 03:52:20 +08:00
|
|
|
static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
|
2004-04-16 13:14:16 +08:00
|
|
|
static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
|
2007-10-15 02:56:15 +08:00
|
|
|
static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
static void ngx_master_process_exit(ngx_cycle_t *cycle);
|
2004-03-04 15:04:55 +08:00
|
|
|
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
|
2004-12-03 02:40:46 +08:00
|
|
|
static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
static void ngx_worker_process_exit(ngx_cycle_t *cycle);
|
2004-06-15 15:55:11 +08:00
|
|
|
static void ngx_channel_handler(ngx_event_t *ev);
|
2004-03-04 15:04:55 +08:00
|
|
|
#if (NGX_THREADS)
|
2004-07-05 14:55:54 +08:00
|
|
|
static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
|
2005-10-19 20:33:58 +08:00
|
|
|
static ngx_thread_value_t ngx_worker_thread_cycle(void *data);
|
2004-03-04 15:04:55 +08:00
|
|
|
#endif
|
2005-03-19 20:38:37 +08:00
|
|
|
#if 0
|
2004-11-21 03:52:20 +08:00
|
|
|
static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data);
|
2005-03-19 20:38:37 +08:00
|
|
|
#endif
|
2004-03-04 15:04:55 +08:00
|
|
|
|
|
|
|
|
2004-04-26 04:13:21 +08:00
|
|
|
ngx_uint_t ngx_process;
|
2004-03-04 15:04:55 +08:00
|
|
|
ngx_pid_t ngx_pid;
|
2004-04-26 04:13:21 +08:00
|
|
|
ngx_uint_t ngx_threaded;
|
2004-03-04 15:04:55 +08:00
|
|
|
|
|
|
|
sig_atomic_t ngx_reap;
|
2004-06-15 15:55:11 +08:00
|
|
|
sig_atomic_t ngx_sigio;
|
2004-03-04 15:04:55 +08:00
|
|
|
sig_atomic_t ngx_terminate;
|
|
|
|
sig_atomic_t ngx_quit;
|
2004-12-21 20:30:30 +08:00
|
|
|
sig_atomic_t ngx_debug_quit;
|
2004-04-26 04:13:21 +08:00
|
|
|
ngx_uint_t ngx_exiting;
|
2004-03-04 15:04:55 +08:00
|
|
|
sig_atomic_t ngx_reconfigure;
|
|
|
|
sig_atomic_t ngx_reopen;
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
sig_atomic_t ngx_change_binary;
|
2004-04-15 23:34:36 +08:00
|
|
|
ngx_pid_t ngx_new_binary;
|
2004-04-26 04:13:21 +08:00
|
|
|
ngx_uint_t ngx_inherited;
|
2004-06-23 23:18:17 +08:00
|
|
|
ngx_uint_t ngx_daemonized;
|
2004-04-15 23:34:36 +08:00
|
|
|
|
|
|
|
sig_atomic_t ngx_noaccept;
|
|
|
|
ngx_uint_t ngx_noaccepting;
|
|
|
|
ngx_uint_t ngx_restart;
|
|
|
|
|
|
|
|
|
2004-07-05 14:55:54 +08:00
|
|
|
#if (NGX_THREADS)
|
|
|
|
volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS];
|
|
|
|
ngx_int_t ngx_threads_n;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
u_long cpu_affinity;
|
|
|
|
static u_char master_process[] = "master process";
|
2004-04-26 04:13:21 +08:00
|
|
|
|
|
|
|
|
2007-08-31 02:59:44 +08:00
|
|
|
static ngx_cycle_t ngx_exit_cycle;
|
|
|
|
static ngx_log_t ngx_exit_log;
|
|
|
|
static ngx_open_file_t ngx_exit_log_file;
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
void
|
|
|
|
ngx_master_process_cycle(ngx_cycle_t *cycle)
|
2004-04-15 23:34:36 +08:00
|
|
|
{
|
2004-04-29 04:21:54 +08:00
|
|
|
char *title;
|
|
|
|
u_char *p;
|
2004-04-26 04:13:21 +08:00
|
|
|
size_t size;
|
2004-06-23 13:54:27 +08:00
|
|
|
ngx_int_t i;
|
2005-07-25 17:41:38 +08:00
|
|
|
ngx_uint_t n;
|
2004-04-15 23:34:36 +08:00
|
|
|
sigset_t set;
|
|
|
|
struct itimerval itv;
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_uint_t live;
|
2004-04-15 23:34:36 +08:00
|
|
|
ngx_msec_t delay;
|
2005-07-25 17:41:38 +08:00
|
|
|
ngx_listening_t *ls;
|
2004-04-15 23:34:36 +08:00
|
|
|
ngx_core_conf_t *ccf;
|
|
|
|
|
|
|
|
sigemptyset(&set);
|
|
|
|
sigaddset(&set, SIGCHLD);
|
|
|
|
sigaddset(&set, SIGALRM);
|
2004-06-15 15:55:11 +08:00
|
|
|
sigaddset(&set, SIGIO);
|
2004-04-15 23:34:36 +08:00
|
|
|
sigaddset(&set, SIGINT);
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL));
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_NOACCEPT_SIGNAL));
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_TERMINATE_SIGNAL));
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL));
|
|
|
|
|
|
|
|
if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"sigprocmask() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
sigemptyset(&set);
|
|
|
|
|
2004-04-26 04:13:21 +08:00
|
|
|
|
|
|
|
size = sizeof(master_process);
|
|
|
|
|
2004-10-11 23:07:03 +08:00
|
|
|
for (i = 0; i < ngx_argc; i++) {
|
|
|
|
size += ngx_strlen(ngx_argv[i]) + 1;
|
2004-04-26 04:13:21 +08:00
|
|
|
}
|
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
title = ngx_pnalloc(cycle->pool, size);
|
2004-04-26 04:13:21 +08:00
|
|
|
|
|
|
|
p = ngx_cpymem(title, master_process, sizeof(master_process) - 1);
|
2004-10-11 23:07:03 +08:00
|
|
|
for (i = 0; i < ngx_argc; i++) {
|
2004-04-26 04:13:21 +08:00
|
|
|
*p++ = ' ';
|
2004-10-11 23:07:03 +08:00
|
|
|
p = ngx_cpystrn(p, (u_char *) ngx_argv[i], size);
|
2004-04-26 04:13:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ngx_setproctitle(title);
|
|
|
|
|
2004-04-15 23:34:36 +08:00
|
|
|
|
|
|
|
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_start_worker_processes(cycle, ccf->worker_processes,
|
|
|
|
NGX_PROCESS_RESPAWN);
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
|
2004-04-15 23:34:36 +08:00
|
|
|
|
|
|
|
ngx_new_binary = 0;
|
|
|
|
delay = 0;
|
|
|
|
live = 1;
|
|
|
|
|
|
|
|
for ( ;; ) {
|
|
|
|
if (delay) {
|
|
|
|
delay *= 2;
|
|
|
|
|
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
|
|
|
"temination cycle: %d", delay);
|
|
|
|
|
|
|
|
itv.it_interval.tv_sec = 0;
|
|
|
|
itv.it_interval.tv_usec = 0;
|
|
|
|
itv.it_value.tv_sec = delay / 1000;
|
|
|
|
itv.it_value.tv_usec = (delay % 1000 ) * 1000;
|
|
|
|
|
|
|
|
if (setitimer(ITIMER_REAL, &itv, NULL) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"setitimer() failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "sigsuspend");
|
|
|
|
|
|
|
|
sigsuspend(&set);
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_time_update(0, 0);
|
2004-04-15 23:34:36 +08:00
|
|
|
|
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "wake up");
|
|
|
|
|
|
|
|
if (ngx_reap) {
|
|
|
|
ngx_reap = 0;
|
2007-10-15 02:56:15 +08:00
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "reap children");
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2007-10-15 02:56:15 +08:00
|
|
|
live = ngx_reap_children(cycle);
|
2004-04-15 23:34:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!live && (ngx_terminate || ngx_quit)) {
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
ngx_master_process_exit(cycle);
|
2004-04-15 23:34:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_terminate) {
|
|
|
|
if (delay == 0) {
|
|
|
|
delay = 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (delay > 1000) {
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_signal_worker_processes(cycle, SIGKILL);
|
2004-04-15 23:34:36 +08:00
|
|
|
} else {
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_signal_worker_processes(cycle,
|
|
|
|
ngx_signal_value(NGX_TERMINATE_SIGNAL));
|
2004-04-15 23:34:36 +08:00
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_quit) {
|
|
|
|
ngx_signal_worker_processes(cycle,
|
|
|
|
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
|
2005-07-25 17:41:38 +08:00
|
|
|
|
|
|
|
ls = cycle->listening.elts;
|
|
|
|
for (n = 0; n < cycle->listening.nelts; n++) {
|
|
|
|
if (ngx_close_socket(ls[n].fd) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
|
|
|
|
ngx_close_socket_n " %V failed",
|
|
|
|
&ls[n].addr_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cycle->listening.nelts = 0;
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
continue;
|
|
|
|
}
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_reconfigure) {
|
|
|
|
ngx_reconfigure = 0;
|
2004-04-29 04:21:54 +08:00
|
|
|
|
|
|
|
if (ngx_new_binary) {
|
|
|
|
ngx_start_worker_processes(cycle, ccf->worker_processes,
|
2004-10-04 04:02:06 +08:00
|
|
|
NGX_PROCESS_RESPAWN);
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
|
2004-10-04 04:02:06 +08:00
|
|
|
ngx_noaccepting = 0;
|
|
|
|
|
2004-04-29 04:21:54 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring");
|
2004-04-15 23:34:36 +08:00
|
|
|
|
|
|
|
cycle = ngx_init_cycle(cycle);
|
|
|
|
if (cycle == NULL) {
|
|
|
|
cycle = (ngx_cycle_t *) ngx_cycle;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_cycle = cycle;
|
|
|
|
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
|
|
|
|
ngx_core_module);
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_start_worker_processes(cycle, ccf->worker_processes,
|
|
|
|
NGX_PROCESS_JUST_RESPAWN);
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_start_garbage_collector(cycle, NGX_PROCESS_JUST_RESPAWN);
|
2004-04-16 13:14:16 +08:00
|
|
|
live = 1;
|
|
|
|
ngx_signal_worker_processes(cycle,
|
|
|
|
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
|
|
|
|
}
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_restart) {
|
2004-04-15 23:34:36 +08:00
|
|
|
ngx_restart = 0;
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_start_worker_processes(cycle, ccf->worker_processes,
|
|
|
|
NGX_PROCESS_RESPAWN);
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
|
2004-04-16 13:14:16 +08:00
|
|
|
live = 1;
|
2004-04-15 23:34:36 +08:00
|
|
|
}
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_reopen) {
|
|
|
|
ngx_reopen = 0;
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_reopen_files(cycle, ccf->user);
|
|
|
|
ngx_signal_worker_processes(cycle,
|
|
|
|
ngx_signal_value(NGX_REOPEN_SIGNAL));
|
2004-04-15 23:34:36 +08:00
|
|
|
}
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_change_binary) {
|
|
|
|
ngx_change_binary = 0;
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "changing binary");
|
2004-10-11 23:07:03 +08:00
|
|
|
ngx_new_binary = ngx_exec_new_binary(cycle, ngx_argv);
|
2004-04-16 13:14:16 +08:00
|
|
|
}
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_noaccept) {
|
|
|
|
ngx_noaccept = 0;
|
|
|
|
ngx_noaccepting = 1;
|
|
|
|
ngx_signal_worker_processes(cycle,
|
|
|
|
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
|
|
|
|
}
|
2004-04-15 23:34:36 +08:00
|
|
|
}
|
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
void
|
|
|
|
ngx_single_process_cycle(ngx_cycle_t *cycle)
|
2004-03-04 15:04:55 +08:00
|
|
|
{
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_uint_t i;
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_init_temp_number();
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
for (i = 0; ngx_modules[i]; i++) {
|
|
|
|
if (ngx_modules[i]->init_process) {
|
|
|
|
if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
2004-03-04 15:04:55 +08:00
|
|
|
}
|
|
|
|
}
|
2004-04-16 13:14:16 +08:00
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
for ( ;; ) {
|
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_process_events_and_timers(cycle);
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_terminate || ngx_quit) {
|
2005-10-27 23:46:13 +08:00
|
|
|
|
|
|
|
for (i = 0; ngx_modules[i]; i++) {
|
|
|
|
if (ngx_modules[i]->exit_process) {
|
|
|
|
ngx_modules[i]->exit_process(cycle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
ngx_master_process_exit(cycle);
|
2004-04-16 13:14:16 +08:00
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_reconfigure) {
|
|
|
|
ngx_reconfigure = 0;
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring");
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
cycle = ngx_init_cycle(cycle);
|
|
|
|
if (cycle == NULL) {
|
|
|
|
cycle = (ngx_cycle_t *) ngx_cycle;
|
|
|
|
continue;
|
2004-03-04 15:04:55 +08:00
|
|
|
}
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_cycle = cycle;
|
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
if (ngx_reopen) {
|
|
|
|
ngx_reopen = 0;
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_reopen_files(cycle, (ngx_uid_t) -1);
|
2004-03-04 15:04:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
|
|
|
ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
|
2004-04-15 23:34:36 +08:00
|
|
|
{
|
2005-11-15 21:30:52 +08:00
|
|
|
ngx_int_t i, s;
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_channel_t ch;
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes");
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2004-06-19 00:22:16 +08:00
|
|
|
ch.command = NGX_CMD_OPEN_CHANNEL;
|
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
|
|
|
cpu_affinity = ngx_get_cpu_affinity(i);
|
|
|
|
|
2004-04-15 23:34:36 +08:00
|
|
|
ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
|
2004-04-16 13:14:16 +08:00
|
|
|
"worker process", type);
|
2004-06-19 00:22:16 +08:00
|
|
|
|
|
|
|
ch.pid = ngx_processes[ngx_process_slot].pid;
|
|
|
|
ch.slot = ngx_process_slot;
|
|
|
|
ch.fd = ngx_processes[ngx_process_slot].channel[0];
|
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
for (s = 0; s < ngx_last_process; s++) {
|
2004-06-19 00:22:16 +08:00
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
if (s == ngx_process_slot
|
|
|
|
|| ngx_processes[s].pid == -1
|
|
|
|
|| ngx_processes[s].channel[0] == -1)
|
2004-10-04 04:02:06 +08:00
|
|
|
{
|
2004-07-14 01:59:12 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-10-04 04:02:06 +08:00
|
|
|
ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
|
|
|
|
ch.slot, ch.pid, ch.fd,
|
2005-11-15 21:30:52 +08:00
|
|
|
s, ngx_processes[s].pid,
|
|
|
|
ngx_processes[s].channel[0]);
|
2004-06-19 00:22:16 +08:00
|
|
|
|
|
|
|
/* TODO: NGX_AGAIN */
|
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
ngx_write_channel(ngx_processes[s].channel[0],
|
2004-06-19 00:22:16 +08:00
|
|
|
&ch, sizeof(ngx_channel_t), cycle->log);
|
|
|
|
}
|
2004-04-15 23:34:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-19 00:22:16 +08:00
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
|
|
|
ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
|
2004-11-21 03:52:20 +08:00
|
|
|
{
|
2005-03-19 20:38:37 +08:00
|
|
|
#if 0
|
|
|
|
ngx_int_t i;
|
|
|
|
ngx_channel_t ch;
|
2004-11-21 03:52:20 +08:00
|
|
|
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector");
|
2004-11-21 03:52:20 +08:00
|
|
|
|
|
|
|
ch.command = NGX_CMD_OPEN_CHANNEL;
|
|
|
|
|
|
|
|
ngx_spawn_process(cycle, ngx_garbage_collector_cycle, NULL,
|
|
|
|
"garbage collector", type);
|
|
|
|
|
|
|
|
ch.pid = ngx_processes[ngx_process_slot].pid;
|
|
|
|
ch.slot = ngx_process_slot;
|
|
|
|
ch.fd = ngx_processes[ngx_process_slot].channel[0];
|
|
|
|
|
|
|
|
for (i = 0; i < ngx_last_process; i++) {
|
|
|
|
|
|
|
|
if (i == ngx_process_slot
|
|
|
|
|| ngx_processes[i].pid == -1
|
|
|
|
|| ngx_processes[i].channel[0] == -1)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
|
|
|
"pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
|
|
|
|
ch.slot, ch.pid, ch.fd,
|
|
|
|
i, ngx_processes[i].pid,
|
|
|
|
ngx_processes[i].channel[0]);
|
|
|
|
|
|
|
|
/* TODO: NGX_AGAIN */
|
|
|
|
|
|
|
|
ngx_write_channel(ngx_processes[i].channel[0],
|
|
|
|
&ch, sizeof(ngx_channel_t), cycle->log);
|
|
|
|
}
|
2005-03-19 20:38:37 +08:00
|
|
|
#endif
|
2004-11-21 03:52:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
|
|
|
ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
|
2004-04-16 13:14:16 +08:00
|
|
|
{
|
2004-06-15 15:55:11 +08:00
|
|
|
ngx_int_t i;
|
|
|
|
ngx_err_t err;
|
|
|
|
ngx_channel_t ch;
|
|
|
|
|
2007-10-18 19:28:21 +08:00
|
|
|
#if (NGX_BROKEN_SCM_RIGHTS)
|
|
|
|
|
|
|
|
ch.command = 0;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2004-06-15 15:55:11 +08:00
|
|
|
switch (signo) {
|
|
|
|
|
|
|
|
case ngx_signal_value(NGX_SHUTDOWN_SIGNAL):
|
|
|
|
ch.command = NGX_CMD_QUIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ngx_signal_value(NGX_TERMINATE_SIGNAL):
|
|
|
|
ch.command = NGX_CMD_TERMINATE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ngx_signal_value(NGX_REOPEN_SIGNAL):
|
|
|
|
ch.command = NGX_CMD_REOPEN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ch.command = 0;
|
|
|
|
}
|
|
|
|
|
2007-10-18 19:28:21 +08:00
|
|
|
#endif
|
|
|
|
|
2004-06-15 15:55:11 +08:00
|
|
|
ch.fd = -1;
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
|
|
|
|
for (i = 0; i < ngx_last_process; i++) {
|
|
|
|
|
2004-10-04 04:02:06 +08:00
|
|
|
ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"child: %d %P e:%d t:%d d:%d r:%d j:%d",
|
2004-10-04 04:02:06 +08:00
|
|
|
i,
|
|
|
|
ngx_processes[i].pid,
|
|
|
|
ngx_processes[i].exiting,
|
|
|
|
ngx_processes[i].exited,
|
|
|
|
ngx_processes[i].detached,
|
|
|
|
ngx_processes[i].respawn,
|
|
|
|
ngx_processes[i].just_respawn);
|
|
|
|
|
2004-07-14 01:59:12 +08:00
|
|
|
if (ngx_processes[i].detached || ngx_processes[i].pid == -1) {
|
2004-04-16 13:14:16 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_processes[i].just_respawn) {
|
|
|
|
ngx_processes[i].just_respawn = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_processes[i].exiting
|
|
|
|
&& signo == ngx_signal_value(NGX_SHUTDOWN_SIGNAL))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-06-15 15:55:11 +08:00
|
|
|
if (ch.command) {
|
|
|
|
if (ngx_write_channel(ngx_processes[i].channel[0],
|
2007-03-07 04:17:50 +08:00
|
|
|
&ch, sizeof(ngx_channel_t), cycle->log)
|
|
|
|
== NGX_OK)
|
2004-06-15 15:55:11 +08:00
|
|
|
{
|
|
|
|
if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
|
|
|
|
ngx_processes[i].exiting = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"kill (%P, %d)" , ngx_processes[i].pid, signo);
|
2004-04-16 13:14:16 +08:00
|
|
|
|
|
|
|
if (kill(ngx_processes[i].pid, signo) == -1) {
|
2004-04-20 15:00:43 +08:00
|
|
|
err = ngx_errno;
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
2004-11-11 22:07:14 +08:00
|
|
|
"kill(%P, %d) failed",
|
2004-04-16 13:14:16 +08:00
|
|
|
ngx_processes[i].pid, signo);
|
2004-04-20 15:00:43 +08:00
|
|
|
|
|
|
|
if (err == NGX_ESRCH) {
|
|
|
|
ngx_processes[i].exited = 1;
|
|
|
|
ngx_processes[i].exiting = 0;
|
|
|
|
ngx_reap = 1;
|
|
|
|
}
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
|
|
|
|
ngx_processes[i].exiting = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-15 23:34:36 +08:00
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static ngx_uint_t
|
2007-10-15 02:56:15 +08:00
|
|
|
ngx_reap_children(ngx_cycle_t *cycle)
|
2004-06-23 13:54:27 +08:00
|
|
|
{
|
2005-09-23 19:02:22 +08:00
|
|
|
ngx_int_t i, n;
|
|
|
|
ngx_uint_t live;
|
|
|
|
ngx_channel_t ch;
|
|
|
|
ngx_core_conf_t *ccf;
|
2004-06-23 13:54:27 +08:00
|
|
|
|
|
|
|
ch.command = NGX_CMD_CLOSE_CHANNEL;
|
|
|
|
ch.fd = -1;
|
|
|
|
|
|
|
|
live = 0;
|
|
|
|
for (i = 0; i < ngx_last_process; i++) {
|
|
|
|
|
2004-07-14 01:59:12 +08:00
|
|
|
ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"child: %d %P e:%d t:%d d:%d r:%d j:%d",
|
2004-07-14 01:59:12 +08:00
|
|
|
i,
|
2004-06-23 13:54:27 +08:00
|
|
|
ngx_processes[i].pid,
|
|
|
|
ngx_processes[i].exiting,
|
|
|
|
ngx_processes[i].exited,
|
|
|
|
ngx_processes[i].detached,
|
|
|
|
ngx_processes[i].respawn,
|
|
|
|
ngx_processes[i].just_respawn);
|
|
|
|
|
2004-07-14 01:59:12 +08:00
|
|
|
if (ngx_processes[i].pid == -1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:54:27 +08:00
|
|
|
if (ngx_processes[i].exited) {
|
|
|
|
|
|
|
|
if (!ngx_processes[i].detached) {
|
|
|
|
ngx_close_channel(ngx_processes[i].channel, cycle->log);
|
|
|
|
|
|
|
|
ngx_processes[i].channel[0] = -1;
|
|
|
|
ngx_processes[i].channel[1] = -1;
|
|
|
|
|
|
|
|
ch.pid = ngx_processes[i].pid;
|
|
|
|
ch.slot = i;
|
|
|
|
|
|
|
|
for (n = 0; n < ngx_last_process; n++) {
|
|
|
|
if (ngx_processes[n].exited
|
2004-07-14 01:59:12 +08:00
|
|
|
|| ngx_processes[n].pid == -1
|
2004-06-23 13:54:27 +08:00
|
|
|
|| ngx_processes[n].channel[0] == -1)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_log_debug3(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"pass close channel s:%i pid:%P to:%P",
|
|
|
|
ch.slot, ch.pid, ngx_processes[n].pid);
|
2004-06-23 13:54:27 +08:00
|
|
|
|
|
|
|
/* TODO: NGX_AGAIN */
|
|
|
|
|
|
|
|
ngx_write_channel(ngx_processes[n].channel[0],
|
|
|
|
&ch, sizeof(ngx_channel_t), cycle->log);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_processes[i].respawn
|
|
|
|
&& !ngx_processes[i].exiting
|
|
|
|
&& !ngx_terminate
|
|
|
|
&& !ngx_quit)
|
|
|
|
{
|
|
|
|
if (ngx_spawn_process(cycle, ngx_processes[i].proc,
|
|
|
|
ngx_processes[i].data,
|
|
|
|
ngx_processes[i].name, i)
|
2005-09-23 19:02:22 +08:00
|
|
|
== NGX_INVALID_PID)
|
2004-06-23 13:54:27 +08:00
|
|
|
{
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
|
|
|
"can not respawn %s", ngx_processes[i].name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
|
|
|
|
ch.command = NGX_CMD_OPEN_CHANNEL;
|
|
|
|
ch.pid = ngx_processes[ngx_process_slot].pid;
|
|
|
|
ch.slot = ngx_process_slot;
|
|
|
|
ch.fd = ngx_processes[ngx_process_slot].channel[0];
|
|
|
|
|
|
|
|
for (n = 0; n < ngx_last_process; n++) {
|
|
|
|
|
|
|
|
if (n == ngx_process_slot
|
|
|
|
|| ngx_processes[n].pid == -1
|
|
|
|
|| ngx_processes[n].channel[0] == -1)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
|
|
|
"pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
|
|
|
|
ch.slot, ch.pid, ch.fd,
|
|
|
|
n, ngx_processes[n].pid,
|
|
|
|
ngx_processes[n].channel[0]);
|
|
|
|
|
|
|
|
/* TODO: NGX_AGAIN */
|
|
|
|
|
|
|
|
ngx_write_channel(ngx_processes[n].channel[0],
|
|
|
|
&ch, sizeof(ngx_channel_t), cycle->log);
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:54:27 +08:00
|
|
|
live = 1;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_processes[i].pid == ngx_new_binary) {
|
2005-09-23 19:02:22 +08:00
|
|
|
|
|
|
|
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
|
|
|
|
ngx_core_module);
|
|
|
|
|
|
|
|
if (ngx_rename_file((char *) ccf->oldpid.data,
|
|
|
|
(char *) ccf->pid.data)
|
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
ngx_rename_file_n " %s back to %s failed "
|
|
|
|
"after the new binary process \"%s\" exited",
|
|
|
|
ccf->oldpid.data, ccf->pid.data, ngx_argv[0]);
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:54:27 +08:00
|
|
|
ngx_new_binary = 0;
|
|
|
|
if (ngx_noaccepting) {
|
|
|
|
ngx_restart = 1;
|
|
|
|
ngx_noaccepting = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 01:59:12 +08:00
|
|
|
if (i == ngx_last_process - 1) {
|
|
|
|
ngx_last_process--;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ngx_processes[i].pid = -1;
|
2004-06-23 13:54:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (ngx_processes[i].exiting || !ngx_processes[i].detached) {
|
|
|
|
live = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return live;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
ngx_master_process_exit(ngx_cycle_t *cycle)
|
2004-03-04 15:04:55 +08:00
|
|
|
{
|
2005-10-27 23:46:13 +08:00
|
|
|
ngx_uint_t i;
|
|
|
|
|
2004-04-12 14:10:53 +08:00
|
|
|
ngx_delete_pidfile(cycle);
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit");
|
2004-04-12 14:10:53 +08:00
|
|
|
|
2005-10-27 23:46:13 +08:00
|
|
|
for (i = 0; ngx_modules[i]; i++) {
|
|
|
|
if (ngx_modules[i]->exit_master) {
|
|
|
|
ngx_modules[i]->exit_master(cycle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-28 22:43:02 +08:00
|
|
|
/*
|
2007-08-31 02:59:44 +08:00
|
|
|
* Copy ngx_cycle->log related data to the special static exit cycle,
|
|
|
|
* log, and log file structures enough to allow a signal handler to log.
|
|
|
|
* The handler may be called when standard ngx_cycle->log allocated from
|
|
|
|
* ngx_cycle->pool is already destroyed.
|
2005-03-28 22:43:02 +08:00
|
|
|
*/
|
|
|
|
|
2007-08-31 02:59:44 +08:00
|
|
|
ngx_exit_log_file.fd = ngx_cycle->log->file->fd;
|
|
|
|
|
|
|
|
ngx_exit_log = *ngx_cycle->log;
|
|
|
|
ngx_exit_log.file = &ngx_exit_log_file;
|
|
|
|
|
|
|
|
ngx_exit_cycle.log = &ngx_exit_log;
|
|
|
|
ngx_cycle = &ngx_exit_cycle;
|
|
|
|
|
2004-04-20 15:00:43 +08:00
|
|
|
ngx_destroy_pool(cycle->pool);
|
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
|
|
|
ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
2004-11-21 03:52:20 +08:00
|
|
|
{
|
2007-03-19 21:20:15 +08:00
|
|
|
ngx_uint_t i;
|
|
|
|
ngx_connection_t *c;
|
2004-11-26 00:17:31 +08:00
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
ngx_worker_process_init(cycle, 1);
|
2004-11-21 03:52:20 +08:00
|
|
|
|
|
|
|
ngx_setproctitle("worker process");
|
|
|
|
|
|
|
|
#if (NGX_THREADS)
|
2007-12-10 20:09:51 +08:00
|
|
|
{
|
|
|
|
ngx_int_t n;
|
|
|
|
ngx_err_t err;
|
|
|
|
ngx_core_conf_t *ccf;
|
2004-11-21 03:52:20 +08:00
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
if (ngx_threads_n) {
|
2007-03-07 04:29:08 +08:00
|
|
|
if (ngx_init_threads(ngx_threads_n, ccf->thread_stack_size, cycle)
|
|
|
|
== NGX_ERROR)
|
2004-11-21 03:52:20 +08:00
|
|
|
{
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ngx_thread_key_create(&ngx_core_tls_key);
|
|
|
|
if (err != 0) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
|
|
|
ngx_thread_key_create_n " failed");
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 0; n < ngx_threads_n; n++) {
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
ngx_threads[n].cv = ngx_cond_init(cycle->log);
|
|
|
|
|
|
|
|
if (ngx_threads[n].cv == NULL) {
|
2004-11-21 03:52:20 +08:00
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid,
|
|
|
|
ngx_worker_thread_cycle,
|
2007-03-07 04:29:08 +08:00
|
|
|
(void *) &ngx_threads[n], cycle->log)
|
|
|
|
!= 0)
|
2004-11-21 03:52:20 +08:00
|
|
|
{
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-10 20:09:51 +08:00
|
|
|
}
|
2004-11-21 03:52:20 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
for ( ;; ) {
|
|
|
|
|
2007-03-19 21:20:15 +08:00
|
|
|
if (ngx_exiting) {
|
|
|
|
|
|
|
|
c = cycle->connections;
|
|
|
|
|
|
|
|
for (i = 0; i < cycle->connection_n; i++) {
|
|
|
|
|
|
|
|
/* THREAD: lock */
|
|
|
|
|
|
|
|
if (c[i].fd != -1 && c[i].idle) {
|
|
|
|
c[i].close = 1;
|
|
|
|
c[i].read->handler(c[i].read);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
|
|
|
|
{
|
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
|
|
|
|
|
|
|
ngx_worker_process_exit(cycle);
|
|
|
|
}
|
2004-11-21 03:52:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_process_events_and_timers(cycle);
|
2004-11-21 03:52:20 +08:00
|
|
|
|
|
|
|
if (ngx_terminate) {
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
2004-11-21 03:52:20 +08:00
|
|
|
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
ngx_worker_process_exit(cycle);
|
2004-11-21 03:52:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_quit) {
|
|
|
|
ngx_quit = 0;
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
|
2004-11-21 03:52:20 +08:00
|
|
|
"gracefully shutting down");
|
|
|
|
ngx_setproctitle("worker process is shutting down");
|
|
|
|
|
|
|
|
if (!ngx_exiting) {
|
|
|
|
ngx_close_listening_sockets(cycle);
|
|
|
|
ngx_exiting = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_reopen) {
|
|
|
|
ngx_reopen = 0;
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_reopen_files(cycle, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
|
|
|
ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
|
2004-03-04 15:04:55 +08:00
|
|
|
{
|
2007-01-21 03:26:48 +08:00
|
|
|
sigset_t set;
|
|
|
|
ngx_int_t n;
|
|
|
|
ngx_uint_t i;
|
|
|
|
struct rlimit rlmt;
|
|
|
|
ngx_core_conf_t *ccf;
|
|
|
|
ngx_listening_t *ls;
|
2004-10-01 23:53:53 +08:00
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
ngx_process = NGX_PROCESS_WORKER;
|
|
|
|
|
2007-01-21 03:26:48 +08:00
|
|
|
if (ngx_set_environment(cycle, NULL) == NULL) {
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
|
|
|
|
2007-08-16 04:53:30 +08:00
|
|
|
if (priority && ccf->priority != 0) {
|
|
|
|
if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"setpriority(%d) failed", ccf->priority);
|
2004-12-03 02:40:46 +08:00
|
|
|
}
|
2007-08-16 04:53:30 +08:00
|
|
|
}
|
2004-12-03 02:40:46 +08:00
|
|
|
|
2007-08-16 04:53:30 +08:00
|
|
|
if (ccf->rlimit_nofile != NGX_CONF_UNSET) {
|
|
|
|
rlmt.rlim_cur = (rlim_t) ccf->rlimit_nofile;
|
|
|
|
rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile;
|
2005-09-23 19:02:22 +08:00
|
|
|
|
2007-08-16 04:53:30 +08:00
|
|
|
if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"setrlimit(RLIMIT_NOFILE, %i) failed",
|
|
|
|
ccf->rlimit_nofile);
|
2005-09-23 19:02:22 +08:00
|
|
|
}
|
2007-08-16 04:53:30 +08:00
|
|
|
}
|
2005-09-23 19:02:22 +08:00
|
|
|
|
2007-08-16 04:53:30 +08:00
|
|
|
if (ccf->rlimit_core != NGX_CONF_UNSET_SIZE) {
|
|
|
|
rlmt.rlim_cur = (rlim_t) ccf->rlimit_core;
|
|
|
|
rlmt.rlim_max = (rlim_t) ccf->rlimit_core;
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2007-08-16 04:53:30 +08:00
|
|
|
if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"setrlimit(RLIMIT_CORE, %i) failed",
|
|
|
|
ccf->rlimit_core);
|
2005-12-16 23:07:08 +08:00
|
|
|
}
|
2007-08-16 04:53:30 +08:00
|
|
|
}
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2005-09-23 19:02:22 +08:00
|
|
|
#ifdef RLIMIT_SIGPENDING
|
2007-08-16 04:53:30 +08:00
|
|
|
if (ccf->rlimit_sigpending != NGX_CONF_UNSET) {
|
|
|
|
rlmt.rlim_cur = (rlim_t) ccf->rlimit_sigpending;
|
|
|
|
rlmt.rlim_max = (rlim_t) ccf->rlimit_sigpending;
|
|
|
|
|
|
|
|
if (setrlimit(RLIMIT_SIGPENDING, &rlmt) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"setrlimit(RLIMIT_SIGPENDING, %i) failed",
|
|
|
|
ccf->rlimit_sigpending);
|
2005-09-23 19:02:22 +08:00
|
|
|
}
|
2007-08-16 04:53:30 +08:00
|
|
|
}
|
2005-09-23 19:02:22 +08:00
|
|
|
#endif
|
|
|
|
|
2007-08-16 04:53:30 +08:00
|
|
|
if (geteuid() == 0) {
|
2004-06-15 15:55:11 +08:00
|
|
|
if (setgid(ccf->group) == -1) {
|
2004-03-04 15:04:55 +08:00
|
|
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
|
|
|
"setgid(%d) failed", ccf->group);
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
if (initgroups(ccf->username, ccf->group) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
|
|
|
"initgroups(%s, %d) failed",
|
|
|
|
ccf->username, ccf->group);
|
|
|
|
}
|
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
if (setuid(ccf->user) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
|
|
|
"setuid(%d) failed", ccf->user);
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
#if (NGX_HAVE_SCHED_SETAFFINITY)
|
|
|
|
|
|
|
|
if (cpu_affinity) {
|
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
|
|
|
|
"sched_setaffinity(0x%08Xl)", cpu_affinity);
|
|
|
|
|
|
|
|
if (sched_setaffinity(0, 32, (cpu_set_t *) &cpu_affinity) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"sched_setaffinity(0x%08Xl) failed", cpu_affinity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-10-21 23:34:38 +08:00
|
|
|
#if (NGX_HAVE_PR_SET_DUMPABLE)
|
2004-03-04 15:04:55 +08:00
|
|
|
|
|
|
|
/* allow coredump after setuid() in Linux 2.4.x */
|
|
|
|
|
|
|
|
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"prctl(PR_SET_DUMPABLE) failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-06-07 23:56:31 +08:00
|
|
|
if (ccf->working_directory.len) {
|
2005-06-16 02:33:41 +08:00
|
|
|
if (chdir((char *) ccf->working_directory.data) == -1) {
|
2005-06-07 23:56:31 +08:00
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"chdir(\"%s\") failed", ccf->working_directory.data);
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
sigemptyset(&set);
|
|
|
|
|
|
|
|
if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
|
|
|
"sigprocmask() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_init_temp_number();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* disable deleting previous events for the listening sockets because
|
|
|
|
* in the worker processes there are no events at all at this point
|
2005-11-15 21:30:52 +08:00
|
|
|
*/
|
2004-03-04 15:04:55 +08:00
|
|
|
ls = cycle->listening.elts;
|
|
|
|
for (i = 0; i < cycle->listening.nelts; i++) {
|
2005-09-23 19:02:22 +08:00
|
|
|
ls[i].previous = NULL;
|
2004-03-04 15:04:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; ngx_modules[i]; i++) {
|
|
|
|
if (ngx_modules[i]->init_process) {
|
|
|
|
if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
|
|
|
|
/* fatal */
|
2004-03-05 00:34:23 +08:00
|
|
|
exit(2);
|
2004-03-04 15:04:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 01:59:12 +08:00
|
|
|
for (n = 0; n < ngx_last_process; n++) {
|
2004-06-16 01:47:16 +08:00
|
|
|
|
2004-07-14 01:59:12 +08:00
|
|
|
if (ngx_processes[n].pid == -1) {
|
2004-06-16 01:47:16 +08:00
|
|
|
continue;
|
2004-07-15 00:01:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (n == ngx_process_slot) {
|
|
|
|
continue;
|
2004-10-04 04:02:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_processes[n].channel[1] == -1) {
|
|
|
|
continue;
|
2004-06-16 01:47:16 +08:00
|
|
|
}
|
2004-06-15 15:55:11 +08:00
|
|
|
|
|
|
|
if (close(ngx_processes[n].channel[1]) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
2004-11-21 03:52:20 +08:00
|
|
|
"close() channel failed");
|
2004-06-15 15:55:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 01:59:12 +08:00
|
|
|
if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
2004-11-21 03:52:20 +08:00
|
|
|
"close() channel failed");
|
2004-07-14 01:59:12 +08:00
|
|
|
}
|
|
|
|
|
2004-06-15 15:55:11 +08:00
|
|
|
#if 0
|
|
|
|
ngx_last_process = 0;
|
|
|
|
#endif
|
|
|
|
|
2004-06-23 23:18:17 +08:00
|
|
|
if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT,
|
2007-03-07 04:29:08 +08:00
|
|
|
ngx_channel_handler)
|
|
|
|
== NGX_ERROR)
|
2004-06-23 23:18:17 +08:00
|
|
|
{
|
|
|
|
/* fatal */
|
|
|
|
exit(2);
|
2004-06-15 15:55:11 +08:00
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
static void
|
|
|
|
ngx_worker_process_exit(ngx_cycle_t *cycle)
|
|
|
|
{
|
|
|
|
ngx_uint_t i;
|
|
|
|
ngx_connection_t *c;
|
|
|
|
|
|
|
|
#if (NGX_THREADS)
|
|
|
|
ngx_terminate = 1;
|
|
|
|
|
|
|
|
ngx_wakeup_worker_threads(cycle);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; ngx_modules[i]; i++) {
|
|
|
|
if (ngx_modules[i]->exit_process) {
|
|
|
|
ngx_modules[i]->exit_process(cycle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-29 04:31:33 +08:00
|
|
|
if (ngx_exiting) {
|
2005-12-07 22:51:31 +08:00
|
|
|
c = cycle->connections;
|
|
|
|
for (i = 0; i < cycle->connection_n; i++) {
|
|
|
|
if (c[i].fd != -1
|
|
|
|
&& c[i].read
|
|
|
|
&& !c[i].read->accept
|
2008-02-29 04:31:33 +08:00
|
|
|
&& !c[i].read->channel
|
|
|
|
&& !c[i].read->resolver)
|
2005-12-07 22:51:31 +08:00
|
|
|
{
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
2008-02-29 04:31:33 +08:00
|
|
|
"open socket #%d left in %ui connection %s",
|
|
|
|
c[i].fd, i, ngx_debug_quit ? ", aborting" : "");
|
2005-12-07 22:51:31 +08:00
|
|
|
ngx_debug_point();
|
|
|
|
}
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
}
|
|
|
|
|
2005-12-07 22:51:31 +08:00
|
|
|
if (ngx_debug_quit) {
|
|
|
|
ngx_debug_point();
|
|
|
|
}
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-08-31 02:59:44 +08:00
|
|
|
* Copy ngx_cycle->log related data to the special static exit cycle,
|
|
|
|
* log, and log file structures enough to allow a signal handler to log.
|
|
|
|
* The handler may be called when standard ngx_cycle->log allocated from
|
|
|
|
* ngx_cycle->pool is already destroyed.
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
*/
|
|
|
|
|
2007-08-31 02:59:44 +08:00
|
|
|
ngx_exit_log_file.fd = ngx_cycle->log->file->fd;
|
|
|
|
|
|
|
|
ngx_exit_log = *ngx_cycle->log;
|
|
|
|
ngx_exit_log.file = &ngx_exit_log_file;
|
|
|
|
|
|
|
|
ngx_exit_cycle.log = &ngx_exit_log;
|
|
|
|
ngx_cycle = &ngx_exit_cycle;
|
|
|
|
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
ngx_destroy_pool(cycle->pool);
|
2007-08-31 02:59:44 +08:00
|
|
|
|
|
|
|
ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, "exit");
|
nginx-0.3.8-RELEASE import
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; the bug had
appeared in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
2005-11-10 01:25:55 +08:00
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
|
|
|
ngx_channel_handler(ngx_event_t *ev)
|
2004-06-15 15:55:11 +08:00
|
|
|
{
|
|
|
|
ngx_int_t n;
|
|
|
|
ngx_channel_t ch;
|
|
|
|
ngx_connection_t *c;
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
if (ev->timedout) {
|
|
|
|
ev->timedout = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-06-15 15:55:11 +08:00
|
|
|
c = ev->data;
|
|
|
|
|
2004-06-17 03:36:07 +08:00
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel handler");
|
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
for ( ;; ) {
|
|
|
|
|
|
|
|
n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log);
|
2004-06-15 15:55:11 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel: %i", n);
|
2004-06-17 03:36:07 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
if (n == NGX_ERROR) {
|
2008-02-20 00:30:54 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
if (ngx_event_flags & NGX_USE_EPOLL_EVENT) {
|
|
|
|
ngx_del_conn(c, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_close_connection(c);
|
|
|
|
return;
|
2008-02-20 00:30:54 +08:00
|
|
|
}
|
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
|
|
|
|
if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2004-11-11 22:07:14 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
if (n == NGX_AGAIN) {
|
2007-03-07 18:25:16 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,
|
|
|
|
"channel command: %d", ch.command);
|
2004-06-15 15:55:11 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
switch (ch.command) {
|
2004-06-17 03:36:07 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
case NGX_CMD_QUIT:
|
|
|
|
ngx_quit = 1;
|
|
|
|
break;
|
2004-06-15 15:55:11 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
case NGX_CMD_TERMINATE:
|
|
|
|
ngx_terminate = 1;
|
|
|
|
break;
|
2004-06-15 15:55:11 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
case NGX_CMD_REOPEN:
|
|
|
|
ngx_reopen = 1;
|
|
|
|
break;
|
2004-06-15 15:55:11 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
case NGX_CMD_OPEN_CHANNEL:
|
2004-06-19 00:22:16 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0,
|
|
|
|
"get channel s:%i pid:%P fd:%d",
|
|
|
|
ch.slot, ch.pid, ch.fd);
|
2004-06-19 00:22:16 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
ngx_processes[ch.slot].pid = ch.pid;
|
|
|
|
ngx_processes[ch.slot].channel[0] = ch.fd;
|
|
|
|
break;
|
2004-06-19 00:22:16 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
case NGX_CMD_CLOSE_CHANNEL:
|
2004-06-23 13:54:27 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0,
|
|
|
|
"close channel s:%i pid:%P our:%P fd:%d",
|
|
|
|
ch.slot, ch.pid, ngx_processes[ch.slot].pid,
|
|
|
|
ngx_processes[ch.slot].channel[0]);
|
2004-06-23 13:54:27 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
if (close(ngx_processes[ch.slot].channel[0]) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
|
|
|
|
"close() channel failed");
|
|
|
|
}
|
2004-06-23 13:54:27 +08:00
|
|
|
|
2008-05-26 02:27:38 +08:00
|
|
|
ngx_processes[ch.slot].channel[0] = -1;
|
|
|
|
break;
|
2004-06-23 13:54:27 +08:00
|
|
|
}
|
2004-06-15 15:55:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-04 15:04:55 +08:00
|
|
|
#if (NGX_THREADS)
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void
|
|
|
|
ngx_wakeup_worker_threads(ngx_cycle_t *cycle)
|
2004-03-04 15:04:55 +08:00
|
|
|
{
|
2004-07-05 14:55:54 +08:00
|
|
|
ngx_int_t i;
|
|
|
|
ngx_uint_t live;
|
|
|
|
|
|
|
|
for ( ;; ) {
|
|
|
|
|
|
|
|
live = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < ngx_threads_n; i++) {
|
|
|
|
if (ngx_threads[i].state < NGX_THREAD_EXIT) {
|
2004-11-26 00:17:31 +08:00
|
|
|
if (ngx_cond_signal(ngx_threads[i].cv) == NGX_ERROR) {
|
2004-07-05 23:08:23 +08:00
|
|
|
ngx_threads[i].state = NGX_THREAD_DONE;
|
2004-11-26 00:17:31 +08:00
|
|
|
|
2004-07-05 23:08:23 +08:00
|
|
|
} else {
|
|
|
|
live = 1;
|
|
|
|
}
|
2004-07-05 14:55:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_threads[i].state == NGX_THREAD_EXIT) {
|
|
|
|
ngx_thread_join(ngx_threads[i].tid, NULL);
|
|
|
|
ngx_threads[i].state = NGX_THREAD_DONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (live == 0) {
|
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
|
|
|
"all worker threads are joined");
|
|
|
|
|
|
|
|
/* STUB */
|
2004-07-07 14:15:04 +08:00
|
|
|
ngx_done_events(cycle);
|
2004-07-05 14:55:54 +08:00
|
|
|
ngx_mutex_destroy(ngx_event_timer_mutex);
|
|
|
|
ngx_mutex_destroy(ngx_posted_events_mutex);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_sched_yield();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
static ngx_thread_value_t
|
2005-03-19 20:38:37 +08:00
|
|
|
ngx_worker_thread_cycle(void *data)
|
2004-07-05 14:55:54 +08:00
|
|
|
{
|
|
|
|
ngx_thread_t *thr = data;
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-07-07 00:12:16 +08:00
|
|
|
sigset_t set;
|
|
|
|
ngx_err_t err;
|
2004-07-07 23:01:00 +08:00
|
|
|
ngx_core_tls_t *tls;
|
2004-07-07 14:15:04 +08:00
|
|
|
ngx_cycle_t *cycle;
|
2004-07-05 14:55:54 +08:00
|
|
|
|
2004-07-07 14:15:04 +08:00
|
|
|
cycle = (ngx_cycle_t *) ngx_cycle;
|
|
|
|
|
2004-07-02 23:54:34 +08:00
|
|
|
sigemptyset(&set);
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL));
|
|
|
|
sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL));
|
2004-03-05 00:34:23 +08:00
|
|
|
|
|
|
|
err = ngx_thread_sigmask(SIG_BLOCK, &set, NULL);
|
|
|
|
if (err) {
|
2004-07-07 14:15:04 +08:00
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
2004-03-05 00:34:23 +08:00
|
|
|
ngx_thread_sigmask_n " failed");
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 1;
|
2004-03-05 00:34:23 +08:00
|
|
|
}
|
|
|
|
|
2004-07-08 03:48:31 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"thread " NGX_TID_T_FMT " started", ngx_thread_self());
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-07-05 14:55:54 +08:00
|
|
|
ngx_setthrtitle("worker thread");
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log);
|
|
|
|
if (tls == NULL) {
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 1;
|
2004-07-07 00:12:16 +08:00
|
|
|
}
|
|
|
|
|
2004-07-07 23:01:00 +08:00
|
|
|
err = ngx_thread_set_tls(ngx_core_tls_key, tls);
|
2004-07-07 00:12:16 +08:00
|
|
|
if (err != 0) {
|
2004-07-07 14:15:04 +08:00
|
|
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
2004-07-07 23:01:00 +08:00
|
|
|
ngx_thread_set_tls_n " failed");
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 1;
|
2004-07-07 00:12:16 +08:00
|
|
|
}
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_mutex_lock(ngx_posted_events_mutex);
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-06-28 02:01:57 +08:00
|
|
|
for ( ;; ) {
|
2004-07-05 14:55:54 +08:00
|
|
|
thr->state = NGX_THREAD_FREE;
|
|
|
|
|
|
|
|
if (ngx_cond_wait(thr->cv, ngx_posted_events_mutex) == NGX_ERROR) {
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 1;
|
2004-06-28 02:01:57 +08:00
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-07-05 14:55:54 +08:00
|
|
|
if (ngx_terminate) {
|
|
|
|
thr->state = NGX_THREAD_EXIT;
|
|
|
|
|
|
|
|
ngx_mutex_unlock(ngx_posted_events_mutex);
|
|
|
|
|
2004-07-07 23:01:00 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"thread " NGX_TID_T_FMT " is done",
|
|
|
|
ngx_thread_self());
|
2004-07-05 14:55:54 +08:00
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 0;
|
2004-06-28 02:01:57 +08:00
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-07-05 14:55:54 +08:00
|
|
|
thr->state = NGX_THREAD_BUSY;
|
2004-03-04 15:04:55 +08:00
|
|
|
|
2004-07-07 14:15:04 +08:00
|
|
|
if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 1;
|
2004-07-07 14:15:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 1;
|
2004-07-07 14:15:04 +08:00
|
|
|
}
|
|
|
|
|
2004-07-07 23:01:00 +08:00
|
|
|
if (ngx_process_changes) {
|
|
|
|
if (ngx_process_changes(cycle, 1) == NGX_ERROR) {
|
2005-10-19 20:33:58 +08:00
|
|
|
return (ngx_thread_value_t) 1;
|
2004-07-07 23:01:00 +08:00
|
|
|
}
|
2004-07-05 14:55:54 +08:00
|
|
|
}
|
|
|
|
}
|
2004-03-04 15:04:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2004-11-21 03:52:20 +08:00
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
#if 0
|
|
|
|
|
|
|
|
static void
|
|
|
|
ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
|
2004-11-21 03:52:20 +08:00
|
|
|
{
|
|
|
|
ngx_uint_t i;
|
|
|
|
ngx_gc_t ctx;
|
|
|
|
ngx_path_t **path;
|
|
|
|
ngx_event_t *ev;
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
ngx_worker_process_init(cycle, 0);
|
2004-11-21 03:52:20 +08:00
|
|
|
|
2005-09-23 19:02:22 +08:00
|
|
|
ev = &cycle->read_events0[ngx_channel];
|
2004-11-21 03:52:20 +08:00
|
|
|
|
|
|
|
ngx_accept_mutex = NULL;
|
|
|
|
|
|
|
|
ngx_setproctitle("garbage collector");
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
ngx_add_timer(ev, 60 * 1000);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for ( ;; ) {
|
|
|
|
|
|
|
|
if (ngx_terminate || ngx_quit) {
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
2004-11-21 03:52:20 +08:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_reopen) {
|
|
|
|
ngx_reopen = 0;
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
|
2004-11-21 03:52:20 +08:00
|
|
|
ngx_reopen_files(cycle, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
path = cycle->pathes.elts;
|
|
|
|
for (i = 0; i < cycle->pathes.nelts; i++) {
|
|
|
|
ctx.path = path[i];
|
|
|
|
ctx.log = cycle->log;
|
nginx-0.1.14-RELEASE import
*) Feature: the autoconfiguration directives:
--http-client-body-temp-path=PATH, --http-proxy-temp-path=PATH, and
--http-fastcgi-temp-path=PATH
*) Change: the directory name for the temporary files with the client
request body is specified by directive client_body_temp_path, by
default it is <prefix>/client_body_temp.
*) Feature: the ngx_http_fastcgi_module and the directives:
fastcgi_pass, fastcgi_root, fastcgi_index, fastcgi_params,
fastcgi_connect_timeout, fastcgi_send_timeout, fastcgi_read_timeout,
fastcgi_send_lowat, fastcgi_header_buffer_size, fastcgi_buffers,
fastcgi_busy_buffers_size, fastcgi_temp_path,
fastcgi_max_temp_file_size, fastcgi_temp_file_write_size,
fastcgi_next_upstream, and fastcgi_x_powered_by.
*) Bugfix: the "[alert] zero size buf" error; the bug had appeared in
0.1.3.
*) Change: the URI must be specified after the host name in the
proxy_pass directive.
*) Change: the %3F symbol in the URI was considered as the argument
string start.
*) Feature: the unix domain sockets support in the
ngx_http_proxy_module.
*) Feature: the ssl_engine and ssl_ciphers directives.
Thanks to Sergey Skvortsov for SSL-accelerator.
2005-01-18 21:03:58 +08:00
|
|
|
ctx.handler = path[i]->cleaner;
|
2004-11-21 03:52:20 +08:00
|
|
|
|
|
|
|
ngx_collect_garbage(&ctx, &path[i]->name, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_add_timer(ev, 60 * 60 * 1000);
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_process_events_and_timers(cycle);
|
2004-11-21 03:52:20 +08:00
|
|
|
}
|
|
|
|
}
|
2005-03-19 20:38:37 +08:00
|
|
|
|
|
|
|
#endif
|