nginx/src/event/ngx_event_accept.c

393 lines
9.6 KiB
C
Raw Normal View History

/*
* Copyright (C) Igor Sysoev
*/
#include <ngx_config.h>
2002-08-26 23:18:19 +08:00
#include <ngx_core.h>
#include <ngx_event.h>
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 ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle);
static ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle);
static void ngx_close_accepted_connection(ngx_connection_t *c);
2003-11-20 00:26:41 +08:00
void
ngx_event_accept(ngx_event_t *ev)
{
2006-09-25 22:34:29 +08:00
socklen_t socklen;
ngx_err_t err;
ngx_log_t *log;
ngx_socket_t s;
ngx_event_t *rev, *wev;
ngx_listening_t *ls;
ngx_connection_t *c, *lc;
ngx_event_conf_t *ecf;
2009-02-21 15:02:02 +08:00
u_char sa[NGX_SOCKADDRLEN];
2003-05-29 21:02:09 +08:00
2003-07-07 14:11:50 +08:00
ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
2003-01-30 15:28:09 +08:00
2004-07-07 23:01:00 +08:00
if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
2004-02-03 05:19:52 +08:00
ev->available = 1;
} else if (!(ngx_event_flags & NGX_USE_KQUEUE_EVENT)) {
2004-02-03 05:19:52 +08:00
ev->available = ecf->multi_accept;
}
lc = ev->data;
ls = lc->listening;
ev->ready = 0;
2002-12-15 14:25:09 +08:00
2004-02-12 01:08:49 +08:00
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"accept on %V, ready: %d", &ls->addr_text, ev->available);
2003-01-30 15:28:09 +08:00
do {
2009-02-21 15:02:02 +08:00
socklen = NGX_SOCKADDRLEN;
2003-05-20 23:37:55 +08:00
2006-09-25 22:34:29 +08:00
s = accept(lc->fd, (struct sockaddr *) sa, &socklen);
2003-01-30 15:28:09 +08:00
if (s == -1) {
err = ngx_socket_errno;
2003-01-30 15:28:09 +08:00
if (err == NGX_EAGAIN) {
2006-09-26 20:20:12 +08:00
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, err,
"accept() not ready");
2003-05-14 00:02:32 +08:00
return;
}
2002-08-26 23:18:19 +08:00
2009-04-20 00:25:02 +08:00
ngx_log_error((ngx_uint_t) ((err == NGX_ECONNABORTED) ?
NGX_LOG_ERR : NGX_LOG_ALERT),
ev->log, err, "accept() failed");
2003-05-29 21:02:09 +08:00
2004-02-03 05:19:52 +08:00
if (err == NGX_ECONNABORTED) {
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
2004-02-03 05:19:52 +08:00
ev->available--;
}
if (ev->available) {
continue;
}
}
2003-05-29 21:02:09 +08:00
return;
}
#if (NGX_STAT_STUB)
ngx_atomic_fetch_add(ngx_stat_accepted, 1);
#endif
2004-04-22 02:54:33 +08:00
2008-09-19 20:47:13 +08:00
ngx_accept_disabled = ngx_cycle->connection_n / 8
- ngx_cycle->free_connection_n;
c = ngx_get_connection(s, ev->log);
if (c == NULL) {
if (ngx_close_socket(s) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno,
ngx_close_socket_n " failed");
}
return;
}
#if (NGX_STAT_STUB)
ngx_atomic_fetch_add(ngx_stat_active, 1);
#endif
c->pool = ngx_create_pool(ls->pool_size, ev->log);
if (c->pool == NULL) {
ngx_close_accepted_connection(c);
return;
}
2003-07-21 05:15:59 +08:00
2006-09-25 22:34:29 +08:00
c->sockaddr = ngx_palloc(c->pool, socklen);
if (c->sockaddr == NULL) {
ngx_close_accepted_connection(c);
return;
}
2003-05-29 21:02:09 +08:00
2006-09-25 22:34:29 +08:00
ngx_memcpy(c->sockaddr, sa, socklen);
2003-05-29 21:02:09 +08:00
log = ngx_palloc(c->pool, sizeof(ngx_log_t));
if (log == NULL) {
ngx_close_accepted_connection(c);
2003-05-14 00:02:32 +08:00
return;
}
2002-08-26 23:18:19 +08:00
/* set a blocking mode for aio and non-blocking mode for others */
2003-05-21 21:28:21 +08:00
if (ngx_inherited_nonblocking) {
if (ngx_event_flags & NGX_USE_AIO_EVENT) {
2003-05-21 21:28:21 +08:00
if (ngx_blocking(s) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno,
2003-11-20 00:26:41 +08:00
ngx_blocking_n " failed");
ngx_close_accepted_connection(c);
2003-05-21 21:28:21 +08:00
return;
}
2003-02-07 01:21:13 +08:00
}
2003-05-21 21:28:21 +08:00
} else {
2004-06-07 03:49:18 +08:00
if (!(ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT))) {
2003-05-21 21:28:21 +08:00
if (ngx_nonblocking(s) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno,
2003-11-20 00:26:41 +08:00
ngx_nonblocking_n " failed");
ngx_close_accepted_connection(c);
2003-05-21 21:28:21 +08:00
return;
}
2003-02-07 01:21:13 +08:00
}
}
*log = ls->log;
2003-06-11 23:28:34 +08:00
c->recv = ngx_recv;
c->send = ngx_send;
c->recv_chain = ngx_recv_chain;
c->send_chain = ngx_send_chain;
2003-06-11 23:28:34 +08:00
c->log = log;
c->pool->log = log;
2002-12-15 14:25:09 +08:00
2006-09-25 22:34:29 +08:00
c->socklen = socklen;
2009-02-21 15:02:02 +08:00
c->listening = ls;
c->local_sockaddr = ls->sockaddr;
c->local_socklen = ls->socklen;
2003-05-12 23:52:24 +08:00
c->unexpected_eof = 1;
2004-07-07 14:15:04 +08:00
rev = c->read;
wev = c->write;
2002-08-26 23:18:19 +08:00
2003-10-29 16:30:44 +08:00
wev->ready = 1;
2004-07-07 23:01:00 +08:00
if (ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT)) {
/* rtsig, aio, iocp */
2003-10-29 16:30:44 +08:00
rev->ready = 1;
2003-02-07 01:21:13 +08:00
}
2004-01-30 05:45:01 +08:00
if (ev->deferred_accept) {
rev->ready = 1;
#if (NGX_HAVE_KQUEUE)
rev->available = 1;
#endif
2004-01-30 05:45:01 +08:00
}
2003-11-20 00:26:41 +08:00
rev->log = log;
wev->log = log;
2003-12-09 04:48:12 +08:00
/*
* TODO: MT: - ngx_atomic_fetch_add()
2004-02-24 04:57:12 +08:00
* or protection by critical section or light mutex
2003-12-09 04:48:12 +08:00
*
* TODO: MP: - allocated in a shared memory
* - ngx_atomic_fetch_add()
2004-02-24 04:57:12 +08:00
* or protection by critical section or light mutex
2003-12-09 04:48:12 +08:00
*/
2003-12-19 16:15:11 +08:00
c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
#if (NGX_STAT_STUB)
ngx_atomic_fetch_add(ngx_stat_handled, 1);
#endif
2004-06-28 02:01:57 +08:00
#if (NGX_THREADS)
rev->lock = &c->lock;
wev->lock = &c->lock;
2004-07-07 14:15:04 +08:00
rev->own_lock = &c->lock;
wev->own_lock = &c->lock;
2004-06-28 02:01:57 +08:00
#endif
if (ls->addr_ntop) {
c->addr_text.data = ngx_pnalloc(c->pool, ls->addr_text_max_len);
if (c->addr_text.data == NULL) {
ngx_close_accepted_connection(c);
return;
}
c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->addr_text.data,
2009-02-21 15:02:02 +08:00
ls->addr_text_max_len, 0);
if (c->addr_text.len == 0) {
ngx_close_accepted_connection(c);
return;
}
}
2004-04-08 23:58:25 +08:00
#if (NGX_DEBUG)
{
in_addr_t i;
ngx_event_debug_t *dc;
struct sockaddr_in *sin;
2004-04-08 23:58:25 +08:00
sin = (struct sockaddr_in *) sa;
dc = ecf->debug_connection.elts;
2004-04-08 23:58:25 +08:00
for (i = 0; i < ecf->debug_connection.nelts; i++) {
if ((sin->sin_addr.s_addr & dc[i].mask) == dc[i].addr) {
2004-04-08 23:58:25 +08:00
log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL;
break;
}
}
}
#endif
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
"*%d accept: %V fd:%d", c->number, &c->addr_text, s);
2004-07-07 23:01:00 +08:00
if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) {
2003-05-29 21:02:09 +08:00
if (ngx_add_conn(c) == NGX_ERROR) {
ngx_close_accepted_connection(c);
2003-05-14 00:02:32 +08:00
return;
2003-03-04 14:33:48 +08:00
}
}
2003-11-20 00:26:41 +08:00
log->data = NULL;
log->handler = NULL;
ls->handler(c);
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ev->available--;
2003-01-30 15:28:09 +08:00
}
2003-11-20 00:26:41 +08:00
} while (ev->available);
}
2003-11-20 00:26:41 +08:00
ngx_int_t
ngx_trylock_accept_mutex(ngx_cycle_t *cycle)
2004-03-31 23:26:46 +08:00
{
if (ngx_shmtx_trylock(&ngx_accept_mutex)) {
2004-03-31 23:26:46 +08:00
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"accept mutex locked");
2006-09-26 20:20:12 +08:00
if (ngx_accept_mutex_held
&& ngx_accept_events == 0
&& !(ngx_event_flags & NGX_USE_RTSIG_EVENT))
{
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
return NGX_OK;
}
2004-03-31 23:26:46 +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
if (ngx_enable_accept_events(cycle) == NGX_ERROR) {
ngx_shmtx_unlock(&ngx_accept_mutex);
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
return NGX_ERROR;
2004-03-31 23:26:46 +08:00
}
2006-09-26 20:20:12 +08:00
ngx_accept_events = 0;
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_accept_mutex_held = 1;
2004-03-31 23:26:46 +08:00
return NGX_OK;
}
2006-09-26 20:20:12 +08:00
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"accept mutex lock failed: %ui", ngx_accept_mutex_held);
2004-04-01 14:21:13 +08:00
if (ngx_accept_mutex_held) {
2004-03-31 23:26:46 +08:00
if (ngx_disable_accept_events(cycle) == NGX_ERROR) {
return NGX_ERROR;
}
2004-04-01 14:21:13 +08:00
ngx_accept_mutex_held = 0;
2004-03-31 23:26:46 +08:00
}
return NGX_OK;
}
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 ngx_int_t
ngx_enable_accept_events(ngx_cycle_t *cycle)
2004-03-31 23:26:46 +08:00
{
ngx_uint_t i;
ngx_listening_t *ls;
ngx_connection_t *c;
2004-03-31 23:26:46 +08:00
ls = cycle->listening.elts;
2004-03-31 23:26:46 +08:00
for (i = 0; i < cycle->listening.nelts; i++) {
c = ls[i].connection;
2004-03-31 23:26:46 +08:00
2004-06-07 03:49:18 +08:00
if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
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
if (ngx_add_conn(c) == NGX_ERROR) {
2004-03-31 23:26:46 +08:00
return NGX_ERROR;
}
} else {
if (ngx_add_event(c->read, NGX_READ_EVENT, 0) == NGX_ERROR) {
2004-03-31 23:26:46 +08:00
return NGX_ERROR;
}
}
}
return NGX_OK;
}
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 ngx_int_t
ngx_disable_accept_events(ngx_cycle_t *cycle)
2004-03-31 23:26:46 +08:00
{
ngx_uint_t i;
ngx_listening_t *ls;
ngx_connection_t *c;
2004-03-31 23:26:46 +08:00
ls = cycle->listening.elts;
2004-03-31 23:26:46 +08:00
for (i = 0; i < cycle->listening.nelts; i++) {
c = ls[i].connection;
2004-03-31 23:26:46 +08:00
if (!c->read->active) {
continue;
}
2004-04-15 01:44:28 +08:00
if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
if (ngx_del_conn(c, NGX_DISABLE_EVENT) == NGX_ERROR) {
2004-03-31 23:26:46 +08:00
return NGX_ERROR;
}
} else {
if (ngx_del_event(c->read, NGX_READ_EVENT, NGX_DISABLE_EVENT)
== NGX_ERROR)
2004-03-31 23:26:46 +08:00
{
return NGX_ERROR;
}
}
}
return NGX_OK;
}
static void
ngx_close_accepted_connection(ngx_connection_t *c)
{
ngx_socket_t fd;
ngx_free_connection(c);
fd = c->fd;
c->fd = (ngx_socket_t) -1;
if (ngx_close_socket(fd) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno,
ngx_close_socket_n " failed");
}
if (c->pool) {
ngx_destroy_pool(c->pool);
}
#if (NGX_STAT_STUB)
ngx_atomic_fetch_add(ngx_stat_active, -1);
#endif
}
u_char *
ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len)
2003-11-20 00:26:41 +08:00
{
return ngx_snprintf(buf, len, " while accepting new connection on %V",
log->data);
2003-11-20 00:26:41 +08:00
}