<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">
#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"
|| err == NGX_EPIPE
#endif
|| err == NGX_ENOTCONN
+#if !(NGX_CRIT_ETIMEDOUT)
+ || err == NGX_ETIMEDOUT
+#endif
|| err == NGX_ECONNREFUSED
|| err == NGX_EHOSTUNREACH)
{
*/
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;
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));
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);
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,
ngx_http_close_request(r, 0);
return;
}
+#endif
if (!ngx_terminate
&& !ngx_exiting
#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 "
/* 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
/* 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) {
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;
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,
}
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)
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) {
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);
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) {
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;
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);
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) {
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) {
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) {
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) {
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,
#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;
}
}
- 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();
+ }
}
/*
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;
}
}
}
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) {
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;
}
return 0;
+
+ } else {
+ return NGX_AGAIN;
}
}
}
/*
* 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) {
#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;
#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;