nginx/src/event/ngx_event_accept.c

389 lines
9.3 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>
/* the buffer size is enough to hold "struct sockaddr_un" */
#define NGX_SOCKLEN 512
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)
{
socklen_t sl;
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;
char sa[NGX_SOCKLEN];
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 {
sl = NGX_SOCKLEN;
2003-05-20 23:37:55 +08:00
s = accept(lc->fd, (struct sockaddr *) sa, &sl);
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) {
2003-05-14 00:02:32 +08:00
return;
}
2002-08-26 23:18:19 +08:00
nginx-0.1.29-RELEASE import *) Feature: the ngx_http_ssi_module supports "include virtual" command. *) Feature: the ngx_http_ssi_module supports the condition command like 'if expr="$NAME"' and "else" and "endif" commands. Only one nested level is supported. *) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and DATE_GMT variables and "config timefmt" command. *) Feature: the "ssi_ignore_recycled_buffers" directive. *) Bugfix: the "echo" command did not show the default value for the empty QUERY_STRING variable. *) Change: the ngx_http_proxy_module was rewritten. *) Feature: the "proxy_redirect", "proxy_pass_request_headers", "proxy_pass_request_body", and "proxy_method" directives. *) Feature: the "proxy_set_header" directive. The "proxy_x_var" was canceled and must be replaced with the proxy_set_header directive. *) Change: the "proxy_preserve_host" is canceled and must be replaced with the "proxy_set_header Host $host" and the "proxy_redirect off" directives, the "proxy_set_header Host $host:$proxy_port" directive and the appropriate proxy_redirect directives. *) Change: the "proxy_set_x_real_ip" is canceled and must be replaced with the "proxy_set_header X-Real-IP $remote_addr" directive. *) Change: the "proxy_add_x_forwarded_for" is canceled and must be replaced with the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for" directive. *) Change: the "proxy_set_x_url" is canceled and must be replaced with the "proxy_set_header X-URL http://$host:$server_port$request_uri" directive. *) Feature: the "fastcgi_param" directive. *) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params" directive are canceled and must be replaced with the fastcgi_param directives. *) Feature: the "index" directive can use the variables. *) Feature: the "index" directive can be used at http and server levels. *) Change: the last index only in the "index" directive can be absolute. *) Feature: the "rewrite" directive can use the variables. *) Feature: the "internal" directive. *) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME, REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables. *) Change: nginx now passes the invalid lines in a client request headers or a backend response header. *) Bugfix: if the backend did not transfer response for a long time and the "send_timeout" was less than "proxy_read_timeout", then nginx returned the 408 response. *) Bugfix: the segmentation fault was occurred if the backend sent an invalid line in response header; the bug had appeared in 0.1.26. *) Bugfix: the segmentation fault may occurred in FastCGI fault tolerance configuration. *) Bugfix: the "expires" directive did not remove the previous "Expires" and "Cache-Control" headers. *) Bugfix: nginx did not take into account trailing dot in "Host" header line. *) Bugfix: the ngx_http_auth_module did not work under Linux. *) Bugfix: the rewrite directive worked incorrectly, if the arguments were in a request. *) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
ngx_log_error((err == NGX_ECONNABORTED) ? NGX_LOG_CRIT:
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);
ngx_atomic_fetch_add(ngx_stat_active, 1);
#endif
2004-04-22 02:54:33 +08:00
ngx_accept_disabled = NGX_ACCEPT_THRESHOLD
- 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;
}
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
c->sockaddr = ngx_palloc(c->pool, sl);
if (c->sockaddr == NULL) {
ngx_close_accepted_connection(c);
return;
}
2003-05-29 21:02:09 +08:00
ngx_memcpy(c->sockaddr, sa, sl);
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
c->listening = ls;
c->socklen = sl;
2003-05-12 23:52:24 +08:00
c->unexpected_eof = 1;
2004-07-07 14:15:04 +08:00
c->ctx = lc->ctx;
c->servers = lc->servers;
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
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
2004-02-24 04:57:12 +08:00
"accept: fd:%d c:%d", s, c->number);
2002-08-26 23:18:19 +08:00
if (ls->addr_ntop) {
c->addr_text.data = ngx_palloc(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(ls->family, c->sockaddr,
c->addr_text.data,
ls->addr_text_max_len);
if (c->addr_text.len == 0) {
ngx_close_accepted_connection(c);
return;
}
}
2004-04-08 23:58:25 +08:00
#if (NGX_DEBUG)
{
uint32_t *addr;
in_addr_t i;
struct sockaddr_in *sin;
2004-04-08 23:58:25 +08:00
sin = (struct sockaddr_in *) sa;
2004-04-08 23:58:25 +08:00
addr = ecf->debug_connection.elts;
for (i = 0; i < ecf->debug_connection.nelts; i++) {
if (addr[i] == sin->sin_addr.s_addr) {
2004-04-08 23:58:25 +08:00
log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL;
break;
}
}
}
#endif
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
{
2004-04-05 04:32:09 +08:00
if (*ngx_accept_mutex == 0
&& ngx_atomic_cmp_set(ngx_accept_mutex, 0, ngx_pid))
{
2004-03-31 23:26:46 +08:00
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"accept mutex locked");
if (ngx_accept_mutex_held && !(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_accept_mutex = 0;
return NGX_ERROR;
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
ngx_accept_mutex_held = 1;
2004-03-31 23:26:46 +08:00
return NGX_OK;
}
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
}