summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES11
-rw-r--r--CHANGES.ru11
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_connection.c3
-rw-r--r--src/event/ngx_event_pipe.c4
-rw-r--r--src/http/modules/ngx_http_static_module.c6
-rw-r--r--src/http/ngx_http_request.c12
-rw-r--r--src/http/ngx_http_request.h5
-rw-r--r--src/http/ngx_http_special_response.c4
-rw-r--r--src/imap/ngx_imap.h2
-rw-r--r--src/imap/ngx_imap_core_module.c11
-rw-r--r--src/imap/ngx_imap_proxy_module.c32
-rw-r--r--src/os/unix/ngx_freebsd_sendfile_chain.c6
-rw-r--r--src/os/unix/ngx_process_cycle.c32
-rw-r--r--src/os/unix/ngx_readv_chain.c23
-rw-r--r--src/os/unix/ngx_recv.c14
-rw-r--r--src/os/unix/ngx_send.c6
-rw-r--r--src/os/unix/ngx_writev_chain.c6
18 files changed, 120 insertions, 70 deletions
diff --git a/CHANGES b/CHANGES
index 4d0cdf8ff..ed44fccb1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,15 @@
+Changes with nginx 0.3.15 07 Dec 2005
+
+ *) Feature: the new 444 code of the "return" directive to close
+ connection.
+
+ *) Feature: the "so_keepalive" directive in IMAP/POP3 proxy.
+
+ *) Bugfix: if there are unclosed connection nginx now calls abort()
+ only on gracefull quit and active "debug_points" directive.
+
+
Changes with nginx 0.3.14 05 Dec 2005
*) Bugfix: in the 304 response the body was transferred; bug appeared
diff --git a/CHANGES.ru b/CHANGES.ru
index 8aea6e3dd..6489eafb3 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,15 @@
+Изменения в nginx 0.3.15 07.12.2005
+
+ *) Добавление: новой код 444 в директиве return для закрытия соединения.
+
+ *) Добавление: директива so_keepalive в IMAP/POP3 прокси.
+
+ *) Исправление: nginx теперь вызывает abort() при обнаружении
+ незакрытых соединений только при планом выходе и включённой
+ директиве debug_points.
+
+
Изменения в nginx 0.3.14 05.12.2005
*) Исправление: в ответе 304 передавалось тело ответа; ошибка появилась
diff --git a/src/core/nginx.h b/src/core/nginx.h
index f99cca8f9..80fd49837 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VER "nginx/0.3.14"
+#define NGINX_VER "nginx/0.3.15"
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ".oldbin"
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 8a8f84a59..0820fede8 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -719,6 +719,9 @@ ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
|| err == NGX_EPIPE
#endif
|| err == NGX_ENOTCONN
+#if !(NGX_CRIT_ETIMEDOUT)
+ || err == NGX_ETIMEDOUT
+#endif
|| err == NGX_ECONNREFUSED
|| err == NGX_EHOSTUNREACH)
{
diff --git a/src/event/ngx_event_pipe.c b/src/event/ngx_event_pipe.c
index 0c499a831..ffb7929dd 100644
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -131,9 +131,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
*/
if (p->upstream->read->available == 0
- && p->upstream->read->pending_eof
- /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
- && p->upstream->read->kq_errno != NGX_ETIMEDOUT)
+ && p->upstream->read->pending_eof)
{
p->upstream->read->ready = 0;
p->upstream->read->eof = 0;
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
index e9d2b395d..ed360faec 100644
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -244,12 +244,12 @@ ngx_http_static_handler(ngx_http_request_t *r)
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- r->allow_ranges = 1;
-
- if (r->header_only || (r->main != r && ngx_file_size(&fi) == 0)) {
+ if (r->main != r && ngx_file_size(&fi) == 0) {
return ngx_http_send_header(r);
}
+ r->allow_ranges = 1;
+
/* we need to allocate all before the header would be sent */
b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 569f62e1d..c6d6d6fc2 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1460,6 +1460,11 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
if (rc >= NGX_HTTP_SPECIAL_RESPONSE || rc == NGX_HTTP_NO_CONTENT) {
+ if (rc == NGX_HTTP_CLOSE) {
+ ngx_http_close_request(r, rc);
+ return;
+ }
+
if (r->main == r) {
if (r->connection->read->timer_set) {
ngx_del_timer(r->connection->read);
@@ -1556,6 +1561,7 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
ngx_del_timer(r->connection->write);
}
+#if 0
if (r->connection->read->pending_eof) {
#if (NGX_HAVE_KQUEUE)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log,
@@ -1565,6 +1571,7 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
ngx_http_close_request(r, 0);
return;
}
+#endif
if (!ngx_terminate
&& !ngx_exiting
@@ -2046,10 +2053,7 @@ ngx_http_keepalive_handler(ngx_event_t *rev)
#if (NGX_HAVE_KQUEUE)
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
- if (rev->pending_eof
- /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
- && rev->kq_errno != NGX_ETIMEDOUT)
- {
+ if (rev->pending_eof) {
c->log->handler = NULL;
ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
"kevent() reported that client %V closed "
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 7b0e7f0da..9e6fd15e0 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -66,7 +66,10 @@
/* Our own HTTP codes */
-#define NGX_HTTP_NGX_CODES NGX_HTTP_TO_HTTPS
+/* The special code to close connection without any response */
+#define NGX_HTTP_CLOSE 444
+
+#define NGX_HTTP_OWN_CODES NGX_HTTP_TO_HTTPS
/*
* We use the special code for the plain HTTP requests that are sent to
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index b8d698f71..f4ad1a771 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -328,14 +328,14 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
/* 3XX */
err = error - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200;
- } else if (error < NGX_HTTP_NGX_CODES) {
+ } else if (error < NGX_HTTP_OWN_CODES) {
/* 4XX */
err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_LEVEL_200
+ NGX_HTTP_LEVEL_300;
} else {
/* 49X, 5XX */
- err = error - NGX_HTTP_NGX_CODES + NGX_HTTP_LEVEL_200
+ err = error - NGX_HTTP_OWN_CODES + NGX_HTTP_LEVEL_200
+ NGX_HTTP_LEVEL_300
+ NGX_HTTP_LEVEL_400;
switch (error) {
diff --git a/src/imap/ngx_imap.h b/src/imap/ngx_imap.h
index 1f3c12eea..90375bfb2 100644
--- a/src/imap/ngx_imap.h
+++ b/src/imap/ngx_imap.h
@@ -40,6 +40,8 @@ typedef struct {
ngx_uint_t protocol;
+ ngx_flag_t so_keepalive;
+
ngx_str_t pop3_capability;
ngx_str_t pop3_starttls_capability;
ngx_str_t imap_capability;
diff --git a/src/imap/ngx_imap_core_module.c b/src/imap/ngx_imap_core_module.c
index e805a8161..44484acc8 100644
--- a/src/imap/ngx_imap_core_module.c
+++ b/src/imap/ngx_imap_core_module.c
@@ -75,6 +75,13 @@ static ngx_command_t ngx_imap_core_commands[] = {
offsetof(ngx_imap_core_srv_conf_t, imap_client_buffer_size),
NULL },
+ { ngx_string("so_keepalive"),
+ NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_IMAP_SRV_CONF_OFFSET,
+ offsetof(ngx_imap_core_srv_conf_t, so_keepalive),
+ NULL },
+
{ ngx_string("timeout"),
NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1,
ngx_conf_set_msec_slot,
@@ -156,8 +163,9 @@ ngx_imap_core_create_srv_conf(ngx_conf_t *cf)
}
cscf->imap_client_buffer_size = NGX_CONF_UNSET_SIZE;
- cscf->timeout = NGX_CONF_UNSET_MSEC;
cscf->protocol = NGX_CONF_UNSET_UINT;
+ cscf->timeout = NGX_CONF_UNSET_MSEC;
+ cscf->so_keepalive = NGX_CONF_UNSET;
if (ngx_array_init(&cscf->pop3_capabilities, cf->pool, 4, sizeof(ngx_str_t))
!= NGX_OK)
@@ -192,6 +200,7 @@ ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
ngx_conf_merge_unsigned_value(conf->protocol, prev->protocol,
NGX_IMAP_IMAP_PROTOCOL);
+ ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0);
if (conf->pop3_capabilities.nelts == 0) {
diff --git a/src/imap/ngx_imap_proxy_module.c b/src/imap/ngx_imap_proxy_module.c
index bdce364b9..7eb1b947b 100644
--- a/src/imap/ngx_imap_proxy_module.c
+++ b/src/imap/ngx_imap_proxy_module.c
@@ -91,10 +91,27 @@ ngx_module_t ngx_imap_proxy_module = {
void
ngx_imap_proxy_init(ngx_imap_session_t *s, ngx_peers_t *peers)
{
+ int keepalive;
ngx_int_t rc;
ngx_imap_proxy_ctx_t *p;
ngx_imap_core_srv_conf_t *cscf;
+ s->connection->log->action = "connecting to upstream";
+
+ cscf = ngx_imap_get_module_srv_conf(s, ngx_imap_core_module);
+
+ if (cscf->so_keepalive) {
+ keepalive = 1;
+
+ if (setsockopt(s->connection->fd, SOL_SOCKET, SO_KEEPALIVE,
+ (const void *) &keepalive, sizeof(int))
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, s->connection->log, ngx_socket_errno,
+ "setsockopt(SO_KEEPALIVE) failed");
+ }
+ }
+
p = ngx_pcalloc(s->connection->pool, sizeof(ngx_imap_proxy_ctx_t));
if (p == NULL) {
ngx_imap_session_internal_server_error(s);
@@ -107,8 +124,6 @@ ngx_imap_proxy_init(ngx_imap_session_t *s, ngx_peers_t *peers)
p->upstream.log = s->connection->log;
p->upstream.log_error = NGX_ERROR_ERR;
- s->connection->log->action = "in upstream auth state";
-
rc = ngx_event_connect_peer(&p->upstream);
if (rc == NGX_ERROR || rc == NGX_BUSY || rc == NGX_DECLINED) {
@@ -116,7 +131,6 @@ ngx_imap_proxy_init(ngx_imap_session_t *s, ngx_peers_t *peers)
return;
}
- cscf = ngx_imap_get_module_srv_conf(s, ngx_imap_core_module);
ngx_add_timer(p->upstream.connection->read, cscf->timeout);
p->upstream.connection->data = s;
@@ -205,6 +219,8 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0,
"imap proxy send login");
+ s->connection->log->action = "sending LOGIN command to upstream";
+
line.len = s->tag.len + sizeof("LOGIN ") - 1
+ 1 + NGX_SIZE_T_LEN + 1 + 2;
line.data = ngx_palloc(c->pool, line.len);
@@ -223,6 +239,8 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
case ngx_imap_login:
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send user");
+ s->connection->log->action = "sending user name to upstream";
+
line.len = s->login.len + 1 + 1 + NGX_SIZE_T_LEN + 1 + 2;
line.data = ngx_palloc(c->pool, line.len);
if (line.data == NULL) {
@@ -241,6 +259,8 @@ ngx_imap_proxy_imap_handler(ngx_event_t *rev)
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0,
"imap proxy send passwd");
+ s->connection->log->action = "sending password to upstream";
+
line.len = s->passwd.len + 2;
line.data = ngx_palloc(c->pool, line.len);
if (line.data == NULL) {
@@ -340,6 +360,8 @@ ngx_imap_proxy_pop3_handler(ngx_event_t *rev)
case ngx_pop3_start:
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send user");
+ s->connection->log->action = "sending user name to upstream";
+
line.len = sizeof("USER ") - 1 + s->login.len + 2;
line.data = ngx_palloc(c->pool, line.len);
if (line.data == NULL) {
@@ -357,6 +379,8 @@ ngx_imap_proxy_pop3_handler(ngx_event_t *rev)
case ngx_pop3_user:
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send pass");
+ s->connection->log->action = "sending password to upstream";
+
line.len = sizeof("PASS ") - 1 + s->passwd.len + 2;
line.data = ngx_palloc(c->pool, line.len);
if (line.data == NULL) {
@@ -431,6 +455,8 @@ ngx_imap_proxy_read_response(ngx_imap_session_t *s, ngx_uint_t what)
ssize_t n;
ngx_buf_t *b;
+ s->connection->log->action = "reading response from upstream";
+
b = s->proxy->buffer;
n = s->proxy->upstream.connection->recv(s->proxy->upstream.connection,
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 662b3347b..7ae594897 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -56,11 +56,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
#if (NGX_HAVE_KQUEUE)
- if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT)
- && wev->pending_eof
- /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
- && wev->kq_errno != NGX_ETIMEDOUT)
- {
+ if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
(void) ngx_connection_error(c, wev->kq_errno,
"kevent() reported about an closed connection");
wev->error = 1;
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index 7adcc6ef7..14bbe80b2 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -938,23 +938,25 @@ ngx_worker_process_exit(ngx_cycle_t *cycle)
}
}
- c = cycle->connections;
- for (i = 0; i < cycle->connection_n; i++) {
- if (c[i].fd != -1
- && c[i].read
- && !c[i].read->accept
- && !c[i].read->channel)
- {
- ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
- "open socket #%d left in %ui connection, "
- "aborting",
- c[i].fd, i);
- ngx_abort();
+ if (ngx_quit) {
+ c = cycle->connections;
+ for (i = 0; i < cycle->connection_n; i++) {
+ if (c[i].fd != -1
+ && c[i].read
+ && !c[i].read->accept
+ && !c[i].read->channel)
+ {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
+ "open socket #%d left in %ui connection, "
+ "aborting",
+ c[i].fd, i);
+ ngx_debug_point();
+ }
}
- }
- if (ngx_debug_quit) {
- ngx_debug_point();
+ if (ngx_debug_quit) {
+ ngx_debug_point();
+ }
}
/*
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index 0e99cb413..b55e2f27e 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -32,26 +32,23 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
rev->pending_eof, rev->available, rev->kq_errno);
if (rev->available == 0) {
-
- if (!rev->pending_eof) {
- return NGX_AGAIN;
- }
-
- /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
- if (rev->kq_errno != NGX_ETIMEDOUT) {
-
+ if (rev->pending_eof) {
rev->ready = 0;
rev->eof = 1;
+ ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
+ "kevent() reported about an closed connection");
+
if (rev->kq_errno) {
rev->error = 1;
ngx_set_socket_errno(rev->kq_errno);
-
- return ngx_connection_error(c, rev->kq_errno,
- "kevent() reported about an closed connection");
+ return NGX_ERROR;
}
return 0;
+
+ } else {
+ return NGX_AGAIN;
}
}
}
@@ -100,8 +97,8 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
rev->available -= n;
/*
- * rev->available can be negative here because some additional
- * bytes can be received between kevent() and recv()
+ * rev->available may be negative here because some additional
+ * bytes may be received between kevent() and recv()
*/
if (rev->available <= 0) {
diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c
index a9064307a..0d3872969 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -25,14 +25,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
rev->pending_eof, rev->available, rev->kq_errno);
if (rev->available == 0) {
-
- if (!rev->pending_eof) {
- return NGX_AGAIN;
- }
-
- /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
- if (rev->kq_errno != NGX_ETIMEDOUT) {
-
+ if (rev->pending_eof) {
rev->ready = 0;
rev->eof = 1;
@@ -45,6 +38,9 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
}
return 0;
+
+ } else {
+ return NGX_AGAIN;
}
}
}
@@ -61,7 +57,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
/*
* rev->available may be negative here because some additional
- * bytes can be received between kevent() and recv()
+ * bytes may be received between kevent() and recv()
*/
if (rev->available <= 0) {
diff --git a/src/os/unix/ngx_send.c b/src/os/unix/ngx_send.c
index 0c3f959da..167f2eca3 100644
--- a/src/os/unix/ngx_send.c
+++ b/src/os/unix/ngx_send.c
@@ -19,11 +19,7 @@ ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
#if (NGX_HAVE_KQUEUE)
- if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT)
- && wev->pending_eof
- /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
- && wev->kq_errno != NGX_ETIMEDOUT)
- {
+ if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
(void) ngx_connection_error(c, wev->kq_errno,
"kevent() reported about an closed connection");
wev->error = 1;
diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c
index 09e08e108..f95c2cad8 100644
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -33,11 +33,7 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
#if (NGX_HAVE_KQUEUE)
- if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT)
- && wev->pending_eof
- /* FreeBSD 5.x-6.x may erroneously report ETIMEDOUT */
- && wev->kq_errno != NGX_ETIMEDOUT)
- {
+ if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
(void) ngx_connection_error(c, wev->kq_errno,
"kevent() reported about an closed connection");
wev->error = 1;