nginx-0.3.15-RELEASE import
*) 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.
This commit is contained in:
parent
abcef763db
commit
a78da273da
17 changed files with 132 additions and 70 deletions
|
@ -9,6 +9,40 @@
|
|||
<title lang="en">nginx changelog</title>
|
||||
|
||||
|
||||
<changes ver="0.3.15" date="07.12.2005">
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÎÏ×ÏÊ ËÏÄ 444 × ÄÉÒÅËÔÉ×Å return ÄÌÑ ÚÁËÒÙÔÉÑ ÓÏÅÄÉÎÅÎÉÑ.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the new 444 code of the "return" directive to close connection.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="feature">
|
||||
<para lang="ru">
|
||||
ÄÉÒÅËÔÉ×Á so_keepalive × IMAP/POP3 ÐÒÏËÓÉ.
|
||||
</para>
|
||||
<para lang="en">
|
||||
the "so_keepalive" directive in IMAP/POP3 proxy.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="bugfix">
|
||||
<para lang="ru">
|
||||
nginx ÔÅÐÅÒØ ×ÙÚÙ×ÁÅÔ abort() ÐÒÉ ÏÂÎÁÒÕÖÅÎÉÉ ÎÅÚÁËÒÙÔÙÈ ÓÏÅÄÉÎÅÎÉÊ
|
||||
ÔÏÌØËÏ ÐÒÉ ÐÌÁÎÏÍ ×ÙÈÏÄÅ É ×ËÌÀÞ£ÎÎÏÊ ÄÉÒÅËÔÉ×Å debug_points.
|
||||
</para>
|
||||
<para lang="en">
|
||||
if there are unclosed connection nginx now calls abort() only on gracefull
|
||||
quit and active "debug_points" directive.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
</changes>
|
||||
|
||||
|
||||
<changes ver="0.3.14" date="05.12.2005">
|
||||
|
||||
<change type="bugfix">
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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 "
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue