summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-05-06 09:29:03 +0000
committerJonathan Kolb <jon@b0g.us>2009-05-06 09:29:03 +0000
commit0a2a082941a6bfc7374c8c7a6c409cbb5cde8455 (patch)
treede748a88acfd6b189eb27bc0d3040836680cd2d8
parent1a537756bb9d3018ea6ab099b22e9734cc8a879d (diff)
downloadnginx-0a2a082941a6bfc7374c8c7a6c409cbb5cde8455.tar.gz
Changes with nginx 0.7.55 06 May 2009v0.7.55
*) Bugfix: the http_XXX parameters in "proxy_cache_use_stale" and "fastcgi_cache_use_stale" directives did not work. *) Bugfix: fastcgi cache did not cache header only responses. *) Bugfix: of "select() failed (9: Bad file descriptor)" error in nginx/Unix and "select() failed (10022: ...)" error in nginx/Windows. *) Bugfix: a segmentation fault might occur in worker process, if an "debug_connection" directive was used; the bug had appeared in 0.7.54. *) Bugfix: fix ngx_http_image_filter_module building errors. *) Bugfix: the files bigger than 2G could not be transferred using $r->sendfile. Thanks to Maxim Dounin.
-rw-r--r--CHANGES21
-rw-r--r--CHANGES.ru23
-rw-r--r--auto/lib/libgd/conf1
-rw-r--r--auto/options1
-rw-r--r--src/core/nginx.h4
-rw-r--r--src/core/ngx_connection.c60
-rw-r--r--src/core/ngx_connection.h11
-rw-r--r--src/core/ngx_cycle.c2
-rw-r--r--src/event/modules/ngx_select_module.c16
-rw-r--r--src/event/ngx_event_pipe.c2
-rw-r--r--src/http/modules/ngx_http_image_filter_module.c2
-rw-r--r--src/http/modules/perl/nginx.pm2
-rw-r--r--src/http/modules/perl/nginx.xs2
-rw-r--r--src/http/ngx_http.c42
-rw-r--r--src/http/ngx_http_upstream.c53
-rw-r--r--src/mail/ngx_mail.c66
-rw-r--r--src/mail/ngx_mail_core_module.c24
-rw-r--r--src/mail/ngx_mail_handler.c22
18 files changed, 198 insertions, 156 deletions
diff --git a/CHANGES b/CHANGES
index c6a657e4c..cc026a3e1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,25 @@
+Changes with nginx 0.7.55 06 May 2009
+
+ *) Bugfix: the http_XXX parameters in "proxy_cache_use_stale" and
+ "fastcgi_cache_use_stale" directives did not work.
+
+ *) Bugfix: fastcgi cache did not cache header only responses.
+
+ *) Bugfix: of "select() failed (9: Bad file descriptor)" error in
+ nginx/Unix and "select() failed (10022: ...)" error in nginx/Windows.
+
+ *) Bugfix: a segmentation fault might occur in worker process, if an
+ "debug_connection" directive was used; the bug had appeared in
+ 0.7.54.
+
+ *) Bugfix: fix ngx_http_image_filter_module building errors.
+
+ *) Bugfix: the files bigger than 2G could not be transferred using
+ $r->sendfile.
+ Thanks to Maxim Dounin.
+
+
Changes with nginx 0.7.54 01 May 2009
*) Feature: the ngx_http_image_filter_module.
diff --git a/CHANGES.ru b/CHANGES.ru
index 63a620089..d8595cf03 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,25 @@
+Изменения в nginx 0.7.55 06.05.2009
+
+ *) Исправление: параметры http_XXX в директиве proxy_cache_use_stale и
+ fastcgi_cache_use_stale не работали.
+
+ *) Исправление: fastcgi кэш не кэшировал ответы, состоящие только из
+ заголовка.
+
+ *) Исправление: ошибки "select() failed (9: Bad file descriptor)" в
+ nginx/Unix и "select() failed (10022: ...)" в nginx/Windows.
+
+ *) Исправление: при использовании директивы debug_connection в рабочем
+ процессе мог произойти segmentation fault; ошибка появилась в 0.7.54.
+
+ *) Исправление: в сборке модуля ngx_http_image_filter_module.
+
+ *) Исправление: файлы больше 2G не передавались с использованием
+ $r->sendfile.
+ Спасибо Максиму Дунину.
+
+
Изменения в nginx 0.7.54 01.05.2009
*) Добавление: модуль ngx_http_image_filter_module.
@@ -41,7 +62,7 @@
*) Добавление: теперь ключи можно задавать в сжатой форме.
*) Исправление: nginx/Windows не работал, если файл конфигурации был
- задан ключём -c.
+ задан ключом -c.
*) Исправление: при использовании директив proxy_store, fastcgi_store,
proxy_cache или fastcgi_cache временные файлы могли не удаляться.
diff --git a/auto/lib/libgd/conf b/auto/lib/libgd/conf
index 3a5277048..637872370 100644
--- a/auto/lib/libgd/conf
+++ b/auto/lib/libgd/conf
@@ -65,6 +65,7 @@ fi
if [ $ngx_found = yes ]; then
+ CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
else
diff --git a/auto/options b/auto/options
index 742a9f825..3b3ee0fae 100644
--- a/auto/options
+++ b/auto/options
@@ -309,6 +309,7 @@ cat << END
--with-http_realip_module enable ngx_http_realip_module
--with-http_addition_module enable ngx_http_addition_module
--with-http_xslt_module enable ngx_http_xslt_module
+ --with-http_image_filter_module enable ngx_http_image_filter_module
--with-http_sub_module enable ngx_http_sub_module
--with-http_dav_module enable ngx_http_dav_module
--with-http_flv_module enable ngx_http_flv_module
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 8d308d6fa..decc0c574 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,8 +8,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 7054
-#define NGINX_VERSION "0.7.54"
+#define nginx_version 7055
+#define NGINX_VERSION "0.7.55"
#define NGINX_VER "nginx/" NGINX_VERSION
#define NGINX_VAR "NGINX"
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 19344ab48..a743dbbed 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -13,11 +13,11 @@ ngx_os_io_t ngx_io;
ngx_listening_t *
-ngx_listening_inet_stream_socket(ngx_conf_t *cf, in_addr_t addr, in_port_t port)
+ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen)
{
- size_t len;
- ngx_listening_t *ls;
- struct sockaddr_in *sin;
+ ngx_listening_t *ls;
+ struct sockaddr *sa;
+ u_char text[NGX_SOCKADDR_STRLEN];
ls = ngx_array_push(&cf->cycle->listening);
if (ls == NULL) {
@@ -26,33 +26,45 @@ ngx_listening_inet_stream_socket(ngx_conf_t *cf, in_addr_t addr, in_port_t port)
ngx_memzero(ls, sizeof(ngx_listening_t));
- sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in));
- if (sin == NULL) {
+ sa = ngx_palloc(cf->pool, socklen);
+ if (sa == NULL) {
return NULL;
}
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = addr;
- sin->sin_port = htons(port);
+ ngx_memcpy(sa, sockaddr, socklen);
+
+ ls->sockaddr = sa;
+ ls->socklen = socklen;
+ ls->addr_text.len = ngx_sock_ntop(sa, text, NGX_SOCKADDR_STRLEN, 1);
- ls->addr_text.data = ngx_pnalloc(cf->pool,
- NGX_INET_ADDRSTRLEN + sizeof(":65535") - 1);
+ ls->addr_text.data = ngx_pnalloc(cf->pool, ls->addr_text.len);
if (ls->addr_text.data == NULL) {
return NULL;
}
- len = ngx_inet_ntop(AF_INET, &addr, ls->addr_text.data,
- NGX_INET_ADDRSTRLEN);
-
- ls->addr_text.len = ngx_sprintf(ls->addr_text.data + len, ":%d", port)
- - ls->addr_text.data;
+ ngx_memcpy(ls->addr_text.data, text, ls->addr_text.len);
ls->fd = (ngx_socket_t) -1;
ls->type = SOCK_STREAM;
- ls->sockaddr = (struct sockaddr *) sin;
- ls->socklen = sizeof(struct sockaddr_in);
- ls->addr_text_max_len = NGX_INET_ADDRSTRLEN;
+
+ switch (ls->sockaddr->sa_family) {
+#if (NGX_HAVE_INET6)
+ case AF_INET6:
+ ls->addr_text_max_len = NGX_INET6_ADDRSTRLEN;
+ break;
+#endif
+ case AF_INET:
+ ls->addr_text_max_len = NGX_INET_ADDRSTRLEN;
+ break;
+ default:
+ ls->addr_text_max_len = NGX_SOCKADDR_STRLEN;
+ break;
+ }
+
+ ls->backlog = NGX_LISTEN_BACKLOG;
+ ls->rcvbuf = -1;
+ ls->sndbuf = -1;
return ls;
}
@@ -248,8 +260,6 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
continue;
}
- ls[i].log = *ls[i].logp;
-
if (ls[i].inherited) {
/* TODO: close on exit */
@@ -295,7 +305,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
(const void *) &ipv6only, sizeof(int))
== -1)
{
- ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
"setsockopt(IPV6_V6ONLY) %V failed, ignored",
&ls[i].addr_text);
}
@@ -319,7 +329,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
}
}
- ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
+ ngx_log_debug2(NGX_LOG_DEBUG_CORE, log, 0,
"bind() %V #%d ", &ls[i].addr_text, s);
if (bind(s, ls[i].sockaddr, ls[i].socklen) == -1) {
@@ -388,7 +398,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
void
-ngx_configure_listening_socket(ngx_cycle_t *cycle)
+ngx_configure_listening_sockets(ngx_cycle_t *cycle)
{
ngx_uint_t i;
ngx_listening_t *ls;
@@ -403,6 +413,8 @@ ngx_configure_listening_socket(ngx_cycle_t *cycle)
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
+ ls[i].log = *ls[i].logp;
+
if (ls[i].rcvbuf != -1) {
if (setsockopt(ls[i].fd, SOL_SOCKET, SO_RCVBUF,
(const void *) &ls[i].rcvbuf, sizeof(int))
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index de0ef41be..7a4c65860 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -163,16 +163,11 @@ struct ngx_connection_s {
};
-#ifndef ngx_ssl_set_nosendshut
-#define ngx_ssl_set_nosendshut(ssl)
-#endif
-
-
-ngx_listening_t *ngx_listening_inet_stream_socket(ngx_conf_t *cf,
- in_addr_t addr, in_port_t port);
+ngx_listening_t *ngx_create_listening(ngx_conf_t *cf, void *sockaddr,
+ socklen_t socklen);
ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle);
ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle);
-void ngx_configure_listening_socket(ngx_cycle_t *cycle);
+void ngx_configure_listening_sockets(ngx_cycle_t *cycle);
void ngx_close_listening_sockets(ngx_cycle_t *cycle);
void ngx_close_connection(ngx_connection_t *c);
ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text);
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 251892b74..fc65765b0 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -573,7 +573,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
if (!ngx_test_config) {
- ngx_configure_listening_socket(cycle);
+ ngx_configure_listening_sockets(cycle);
}
}
diff --git a/src/event/modules/ngx_select_module.c b/src/event/modules/ngx_select_module.c
index 9be2c6ff3..667aea5da 100644
--- a/src/event/modules/ngx_select_module.c
+++ b/src/event/modules/ngx_select_module.c
@@ -147,6 +147,16 @@ ngx_select_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
return NGX_OK;
}
+ if ((event == NGX_READ_EVENT && ev->write)
+ || (event == NGX_WRITE_EVENT && !ev->write))
+ {
+ ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
+ "invalid select %s event fd:%d ev:%i",
+ ev->write ? "write" : "read", c->fd, event);
+ return NGX_ERROR;
+ }
+
+
#if (NGX_WIN32)
if ((event == NGX_READ_EVENT) && (max_read >= FD_SETSIZE)
@@ -195,6 +205,7 @@ ngx_select_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
static ngx_int_t
ngx_select_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
+ ngx_event_t *e;
ngx_connection_t *c;
c = ev->data;
@@ -235,8 +246,9 @@ ngx_select_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
#endif
if (ev->index < --nevents) {
- event_index[ev->index] = event_index[nevents];
- event_index[ev->index]->index = ev->index;
+ e = event_index[nevents];
+ event_index[ev->index] = e;
+ e->index = ev->index;
}
ev->index = NGX_INVALID_INDEX;
diff --git a/src/event/ngx_event_pipe.c b/src/event/ngx_event_pipe.c
index c13d2ea5a..5d5035ce2 100644
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -397,7 +397,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
p->free_raw_bufs = p->free_raw_bufs->next;
- if (p->free_bufs) {
+ if (p->free_bufs && p->buf_to_file == NULL) {
for (cl = p->free_raw_bufs; cl; cl = cl->next) {
if (cl->buf->shadow == NULL) {
ngx_pfree(p->pool, cl->buf->start);
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
index a5af1ac2e..10fefc549 100644
--- a/src/http/modules/ngx_http_image_filter_module.c
+++ b/src/http/modules/ngx_http_image_filter_module.c
@@ -186,7 +186,7 @@ ngx_http_image_header_filter(ngx_http_request_t *r)
len = r->headers_out.content_length_n;
- if (len != -1 && len > conf->buffer_size) {
+ if (len != -1 && len > (off_t) conf->buffer_size) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"image filter: too big response: %O", len);
diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm
index 47bc83e24..2c5b74f62 100644
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -47,7 +47,7 @@ our @EXPORT = qw(
HTTP_INSUFFICIENT_STORAGE
);
-our $VERSION = '0.7.54';
+our $VERSION = '0.7.55';
require XSLoader;
XSLoader::load('nginx', $VERSION);
diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs
index 66b0f59b2..077cf0ddf 100644
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -607,7 +607,7 @@ sendfile(r, filename, offset = -1, bytes = 0)
ngx_http_request_t *r;
char *filename;
- int offset;
+ off_t offset;
size_t bytes;
ngx_str_t path;
ngx_buf_t *b;
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 5e487e75c..a9b4ee5c5 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1688,54 +1688,14 @@ static ngx_listening_t *
ngx_http_add_listening(ngx_conf_t *cf, ngx_http_conf_addr_t *addr)
{
ngx_listening_t *ls;
- struct sockaddr *sa;
ngx_http_core_loc_conf_t *clcf;
ngx_http_core_srv_conf_t *cscf;
- u_char text[NGX_SOCKADDR_STRLEN];
- ls = ngx_array_push(&cf->cycle->listening);
+ ls = ngx_create_listening(cf, addr->sockaddr, addr->socklen);
if (ls == NULL) {
return NULL;
}
- ngx_memzero(ls, sizeof(ngx_listening_t));
-
- sa = ngx_palloc(cf->pool, addr->socklen);
- if (sa == NULL) {
- return NULL;
- }
-
- ngx_memcpy(sa, addr->sockaddr, addr->socklen);
-
- ls->sockaddr = sa;
- ls->socklen = addr->socklen;
-
- ls->addr_text.len = ngx_sock_ntop(sa, text, NGX_SOCKADDR_STRLEN, 1);
-
- ls->addr_text.data = ngx_pnalloc(cf->pool, ls->addr_text.len);
- if (ls->addr_text.data == NULL) {
- return NULL;
- }
-
- ngx_memcpy(ls->addr_text.data, text, ls->addr_text.len);
-
- ls->fd = (ngx_socket_t) -1;
- ls->type = SOCK_STREAM;
-
- switch (ls->sockaddr->sa_family) {
-#if (NGX_HAVE_INET6)
- case AF_INET6:
- ls->addr_text_max_len = NGX_INET6_ADDRSTRLEN;
- break;
-#endif
- case AF_INET:
- ls->addr_text_max_len = NGX_INET_ADDRSTRLEN;
- break;
- default:
- ls->addr_text_max_len = NGX_SOCKADDR_STRLEN;
- break;
- }
-
ls->addr_ntop = 1;
ls->handler = ngx_http_init_connection;
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 2cf45625d..b21d01ab9 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -768,6 +768,7 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
int n;
char buf[1];
ngx_err_t err;
+ ngx_int_t event;
ngx_connection_t *c;
ngx_http_upstream_t *u;
@@ -779,10 +780,22 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
u = r->upstream;
if (c->error) {
+ if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) {
+
+ event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT;
+
+ if (ngx_del_event(ev, event, 0) != NGX_OK) {
+ ngx_http_upstream_finalize_request(r, u,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+ }
+
if (!u->cacheable) {
ngx_http_upstream_finalize_request(r, u,
NGX_HTTP_CLIENT_CLOSED_REQUEST);
}
+
return;
}
@@ -836,17 +849,15 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err,
"http upstream recv(): %d", n);
- /*
- * we do not need to disable the write event because
- * that event has NGX_USE_CLEAR_EVENT type
- */
-
if (ev->write && (n >= 0 || err == NGX_EAGAIN)) {
return;
}
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) {
- if (ngx_del_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
+
+ event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT;
+
+ if (ngx_del_event(ev, event, 0) != NGX_OK) {
ngx_http_upstream_finalize_request(r, u,
NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
@@ -1472,13 +1483,10 @@ ngx_http_upstream_process_header(ngx_http_request_t *r, ngx_http_upstream_t *u)
static ngx_int_t
ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)
{
+ ngx_int_t rc;
ngx_uint_t status;
ngx_http_upstream_next_t *un;
- if (!(u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_STATUS)) {
- return NGX_DECLINED;
- }
-
status = u->headers_in.status_n;
for (un = ngx_http_upstream_next_errors; un->status; un++) {
@@ -1494,12 +1502,15 @@ ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)
#if (NGX_HTTP_CACHE)
- if (u->peer.tries == 0
- && u->stale_cache
- && (u->conf->cache_use_stale & un->mask))
- {
- ngx_http_upstream_finalize_request(r, u,
- ngx_http_upstream_cache_send(r, u));
+ if (u->stale_cache && (u->conf->cache_use_stale & un->mask)) {
+
+ rc = u->reinit_request(r);
+
+ if (rc == NGX_OK) {
+ rc = ngx_http_upstream_cache_send(r, u);
+ }
+
+ ngx_http_upstream_finalize_request(r, u, rc);
return NGX_OK;
}
@@ -2650,9 +2661,15 @@ ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
#if (NGX_HTTP_CACHE)
if (u->stale_cache && (u->conf->cache_use_stale & ft_type)) {
+ ngx_int_t rc;
- ngx_http_upstream_finalize_request(r, u,
- ngx_http_upstream_cache_send(r, u));
+ rc = u->reinit_request(r);
+
+ if (rc == NGX_OK) {
+ rc = ngx_http_upstream_cache_send(r, u);
+ }
+
+ ngx_http_upstream_finalize_request(r, u, rc);
return;
}
#endif
diff --git a/src/mail/ngx_mail.c b/src/mail/ngx_mail.c
index 1d6b78bdd..3ed900d2f 100644
--- a/src/mail/ngx_mail.c
+++ b/src/mail/ngx_mail.c
@@ -70,9 +70,10 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_conf_t pcf;
ngx_array_t in_ports;
ngx_listening_t *ls;
- ngx_mail_listen_t *imls;
+ ngx_mail_listen_t *mls;
ngx_mail_module_t *module;
- ngx_mail_in_port_t *imip;
+ struct sockaddr_in sin;
+ ngx_mail_in_port_t *mip;
ngx_mail_conf_ctx_t *ctx;
ngx_mail_conf_in_port_t *in_port;
ngx_mail_conf_in_addr_t *in_addr;
@@ -223,7 +224,7 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- imls = cmcf->listen.elts;
+ mls = cmcf->listen.elts;
for (l = 0; l < cmcf->listen.nelts; l++) {
@@ -231,7 +232,7 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
in_port = in_ports.elts;
for (p = 0; p < in_ports.nelts; p++) {
- if (in_port[p].port == imls[l].port) {
+ if (in_port[p].port == mls[l].port) {
in_port = &in_port[p];
goto found;
}
@@ -242,7 +243,7 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- in_port->port = imls[l].port;
+ in_port->port = mls[l].port;
if (ngx_array_init(&in_port->addrs, cf->temp_pool, 2,
sizeof(ngx_mail_conf_in_addr_t))
@@ -258,11 +259,11 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- in_addr->addr = imls[l].addr;
- in_addr->ctx = imls[l].ctx;
- in_addr->bind = imls[l].bind;
+ in_addr->addr = mls[l].addr;
+ in_addr->ctx = mls[l].ctx;
+ in_addr->bind = mls[l].bind;
#if (NGX_MAIL_SSL)
- in_addr->ssl = imls[l].ssl;
+ in_addr->ssl = mls[l].ssl;
#endif
}
@@ -299,16 +300,17 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
continue;
}
- ls = ngx_listening_inet_stream_socket(cf, in_addr[a].addr,
- in_port[p].port);
+ ngx_memzero(&sin, sizeof(struct sockaddr_in));
+
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = in_addr[a].addr;
+ sin.sin_port = htons(in_port[p].port);
+
+ ls = ngx_create_listening(cf, &sin, sizeof(struct sockaddr_in));
if (ls == NULL) {
- return NGX_CONF_ERROR;
+ return NULL;
}
- ls->backlog = NGX_LISTEN_BACKLOG;
- ls->rcvbuf = -1;
- ls->sndbuf = -1;
-
ls->addr_ntop = 1;
ls->handler = ngx_mail_init_connection;
ls->pool_size = 256;
@@ -318,27 +320,27 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ls->log.data = &ls->addr_text;
ls->log.handler = ngx_accept_log_error;
- imip = ngx_palloc(cf->pool, sizeof(ngx_mail_in_port_t));
- if (imip == NULL) {
+ mip = ngx_palloc(cf->pool, sizeof(ngx_mail_in_port_t));
+ if (mip == NULL) {
return NGX_CONF_ERROR;
}
- ls->servers = imip;
+ ls->servers = mip;
in_addr = in_port[p].addrs.elts;
if (in_addr[a].bind && in_addr[a].addr != INADDR_ANY) {
- imip->naddrs = 1;
+ mip->naddrs = 1;
done = 0;
} else if (in_port[p].addrs.nelts > 1
&& in_addr[last - 1].addr == INADDR_ANY)
{
- imip->naddrs = last;
+ mip->naddrs = last;
done = 1;
} else {
- imip->naddrs = 1;
+ mip->naddrs = 1;
done = 0;
}
@@ -346,18 +348,18 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
"%ui: %V %d %ui %ui",
a, &ls->addr_text, in_addr[a].bind,
- imip->naddrs, last);
+ mip->naddrs, last);
#endif
- imip->addrs = ngx_pcalloc(cf->pool,
- imip->naddrs * sizeof(ngx_mail_in_addr_t));
- if (imip->addrs == NULL) {
+ mip->addrs = ngx_pcalloc(cf->pool,
+ mip->naddrs * sizeof(ngx_mail_in_addr_t));
+ if (mip->addrs == NULL) {
return NGX_CONF_ERROR;
}
- for (i = 0; i < imip->naddrs; i++) {
- imip->addrs[i].addr = in_addr[i].addr;
- imip->addrs[i].ctx = in_addr[i].ctx;
+ for (i = 0; i < mip->naddrs; i++) {
+ mip->addrs[i].addr = in_addr[i].addr;
+ mip->addrs[i].ctx = in_addr[i].ctx;
text = ngx_pnalloc(cf->pool,
NGX_INET_ADDRSTRLEN + sizeof(":65535") - 1);
@@ -370,11 +372,11 @@ ngx_mail_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
len = ngx_sprintf(text + len, ":%d", in_port[p].port) - text;
- imip->addrs[i].addr_text.len = len;
- imip->addrs[i].addr_text.data = text;
+ mip->addrs[i].addr_text.len = len;
+ mip->addrs[i].addr_text.data = text;
#if (NGX_MAIL_SSL)
- imip->addrs[i].ssl = in_addr[i].ssl;
+ mip->addrs[i].ssl = in_addr[i].ssl;
#endif
}
diff --git a/src/mail/ngx_mail_core_module.c b/src/mail/ngx_mail_core_module.c
index a9cd6a4da..976066284 100644
--- a/src/mail/ngx_mail_core_module.c
+++ b/src/mail/ngx_mail_core_module.c
@@ -284,7 +284,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_str_t *value;
ngx_url_t u;
ngx_uint_t i, m;
- ngx_mail_listen_t *imls;
+ ngx_mail_listen_t *ls;
ngx_mail_module_t *module;
ngx_mail_core_main_conf_t *cmcf;
@@ -312,11 +312,11 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
cmcf = ngx_mail_conf_get_module_main_conf(cf, ngx_mail_core_module);
- imls = cmcf->listen.elts;
+ ls = cmcf->listen.elts;
for (i = 0; i < cmcf->listen.nelts; i++) {
- if (imls[i].addr != u.addr.in_addr || imls[i].port != u.port) {
+ if (ls[i].addr != u.addr.in_addr || ls[i].port != u.port) {
continue;
}
@@ -325,17 +325,17 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- imls = ngx_array_push(&cmcf->listen);
- if (imls == NULL) {
+ ls = ngx_array_push(&cmcf->listen);
+ if (ls == NULL) {
return NGX_CONF_ERROR;
}
- ngx_memzero(imls, sizeof(ngx_mail_listen_t));
+ ngx_memzero(ls, sizeof(ngx_mail_listen_t));
- imls->addr = u.addr.in_addr;
- imls->port = u.port;
- imls->family = u.family;
- imls->ctx = cf->ctx;
+ ls->addr = u.addr.in_addr;
+ ls->port = u.port;
+ ls->family = u.family;
+ ls->ctx = cf->ctx;
for (m = 0; ngx_modules[m]; m++) {
if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
@@ -359,13 +359,13 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
for (i = 2; i < cf->args->nelts; i++) {
if (ngx_strcmp(value[i].data, "bind") == 0) {
- imls->bind = 1;
+ ls->bind = 1;
continue;
}
if (ngx_strcmp(value[i].data, "ssl") == 0) {
#if (NGX_MAIL_SSL)
- imls->ssl = 1;
+ ls->ssl = 1;
continue;
#else
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
diff --git a/src/mail/ngx_mail_handler.c b/src/mail/ngx_mail_handler.c
index 0863d6dfe..44ebdede2 100644
--- a/src/mail/ngx_mail_handler.c
+++ b/src/mail/ngx_mail_handler.c
@@ -26,20 +26,20 @@ ngx_mail_init_connection(ngx_connection_t *c)
ngx_uint_t i;
struct sockaddr_in sin;
ngx_mail_log_ctx_t *ctx;
- ngx_mail_in_port_t *imip;
- ngx_mail_in_addr_t *imia;
+ ngx_mail_in_port_t *mip;
+ ngx_mail_in_addr_t *mia;
ngx_mail_session_t *s;
/* find the server configuration for the address:port */
/* AF_INET only */
- imip = c->listening->servers;
- imia = imip->addrs;
+ mip = c->listening->servers;
+ mia = mip->addrs;
i = 0;
- if (imip->naddrs > 1) {
+ if (mip->naddrs > 1) {
/*
* There are several addresses on this port and one of them
@@ -70,8 +70,8 @@ ngx_mail_init_connection(ngx_connection_t *c)
/* the last address is "*" */
- for ( /* void */ ; i < imip->naddrs - 1; i++) {
- if (in_addr == imia[i].addr) {
+ for ( /* void */ ; i < mip->naddrs - 1; i++) {
+ if (in_addr == mia[i].addr) {
break;
}
}
@@ -84,10 +84,10 @@ ngx_mail_init_connection(ngx_connection_t *c)
return;
}
- s->main_conf = imia[i].ctx->main_conf;
- s->srv_conf = imia[i].ctx->srv_conf;
+ s->main_conf = mia[i].ctx->main_conf;
+ s->srv_conf = mia[i].ctx->srv_conf;
- s->addr_text = &imia[i].addr_text;
+ s->addr_text = &mia[i].addr_text;
c->data = s;
s->connection = c;
@@ -124,7 +124,7 @@ ngx_mail_init_connection(ngx_connection_t *c)
return;
}
- if (imia[i].ssl) {
+ if (mia[i].ssl) {
c->log->action = "SSL handshaking";