summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-07-11 13:16:58 +0000
committerJonathan Kolb <jon@b0g.us>2006-07-11 13:16:58 +0000
commit2b3fe4925694feab4cc6c13997211a45a35b116f (patch)
tree230afcd3b726473674d0119ad7c248622d94a1bd
parentfdd764835945d7a6d9ca2bc9c8bc44635f27b608 (diff)
downloadnginx-0.3.54.tar.gz
Changes with nginx 0.3.54 11 Jul 2006v0.3.54
*) Feature: nginx now logs the subrequest information to the error log. *) Feature: the "proxy_next_upstream", "fastcgi_next_upstream", and "memcached_next_upstream" directives support the "off" parameter. *) Feature: the "debug_connection" directive supports the CIDR address form. *) Bugfix: if a response of proxied server or FastCGI server was converted from UTF-8 or back, then it may be transferred incomplete. *) Bugfix: the $upstream_response_time variable had the time of the first request to a backend only. *) Bugfix: nginx could not be built on amd64 platform; bug appeared in 0.3.53.
-rw-r--r--CHANGES22
-rw-r--r--CHANGES.ru21
-rw-r--r--auto/make40
-rwxr-xr-xauto/unix9
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/event/ngx_event.c27
-rw-r--r--src/event/ngx_event.h6
-rw-r--r--src/event/ngx_event_accept.c12
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c11
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c6
-rw-r--r--src/http/modules/ngx_http_memcached_module.c6
-rw-r--r--src/http/modules/ngx_http_proxy_module.c6
-rw-r--r--src/http/ngx_http.h5
-rw-r--r--src/http/ngx_http_core_module.c4
-rw-r--r--src/http/ngx_http_postpone_filter_module.c4
-rw-r--r--src/http/ngx_http_request.c47
-rw-r--r--src/http/ngx_http_request_body.c6
-rw-r--r--src/http/ngx_http_upstream.c74
-rw-r--r--src/http/ngx_http_upstream.h19
19 files changed, 210 insertions, 117 deletions
diff --git a/CHANGES b/CHANGES
index 31b2672a9..066fe1f07 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,24 @@
+Changes with nginx 0.3.54 11 Jul 2006
+
+ *) Feature: nginx now logs the subrequest information to the error log.
+
+ *) Feature: the "proxy_next_upstream", "fastcgi_next_upstream", and
+ "memcached_next_upstream" directives support the "off" parameter.
+
+ *) Feature: the "debug_connection" directive supports the CIDR address
+ form.
+
+ *) Bugfix: if a response of proxied server or FastCGI server was
+ converted from UTF-8 or back, then it may be transferred incomplete.
+
+ *) Bugfix: the $upstream_response_time variable had the time of the
+ first request to a backend only.
+
+ *) Bugfix: nginx could not be built on amd64 platform; bug appeared in
+ 0.3.53.
+
+
Changes with nginx 0.3.53 07 Jul 2006
*) Change: the "add_header" directive adds the string to 204, 301, and
@@ -12,7 +32,7 @@ Changes with nginx 0.3.53 07 Jul 2006
*) Feature: nginx supports the request body size more than 2G.
*) Bugfix: if a client was successfully authorized using "satisfy_any
- on", then anyway the "access forbidden by rule" message was written
+ on", then anyway the message "access forbidden by rule" was written
in the log.
*) Bugfix: the "PUT" method may erroneously not create a file and
diff --git a/CHANGES.ru b/CHANGES.ru
index 619898632..90ecd0ae8 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,25 @@
+Изменения в nginx 0.3.54 11.07.2006
+
+ *) Добавление: nginx теперь записывает в лог информацию о подзапросах.
+
+ *) Добавление: директивы proxy_next_upstream, fastcgi_next_upstream и
+ memcached_next_upstream поддерживают параметр off.
+
+ *) Добавление: директива debug_connection поддерживает запись адресов в
+ формате CIDR.
+
+ *) Исправление: при перекодировании ответа проксированного сервера или
+ сервера FastCGI в UTF-8 или наоборот ответ мог передаваться не
+ полностью.
+
+ *) Исправление: переменная $upstream_response_time содержала время
+ только первого обращения к бэкенду.
+
+ *) Исправление: nginx не собирался на платформе amd64; ошибка появилась
+ в 0.3.53.
+
+
Изменения в nginx 0.3.53 07.07.2006
*) Изменение: директива add_header добавляет строки в ответы с кодом
diff --git a/auto/make b/auto/make
index 346770ac9..4a2cd0c05 100644
--- a/auto/make
+++ b/auto/make
@@ -150,10 +150,10 @@ do
done
ngx_all_objs=`echo $ngx_all_srcs \
- | sed -e "s/\([^ ]*\.\)cpp/$NGX_OBJS\/\1$ngx_objext/g" \
- -e "s/\([^ ]*\.\)cc/$NGX_OBJS\/\1$ngx_objext/g" \
- -e "s/\([^ ]*\.\)c/$NGX_OBJS\/\1$ngx_objext/g" \
- -e "s/\([^ ]*\.\)S/$NGX_OBJS\/\1$ngx_objext/g"`
+ | sed -e "s#\([^ ]*\.\)cpp#$NGX_OBJS\/\1$ngx_objext#g" \
+ -e "s#\([^ ]*\.\)cc#$NGX_OBJS\/\1$ngx_objext#g" \
+ -e "s#\([^ ]*\.\)c#$NGX_OBJS\/\1$ngx_objext#g" \
+ -e "s#\([^ ]*\.\)S#$NGX_OBJS\/\1$ngx_objext#g"`
ngx_modules_c=`echo $NGX_MODULES_C | sed -e "s/\//$ngx_regex_dirsep/g"`
@@ -213,10 +213,10 @@ for ngx_src in $CORE_SRCS
do
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=`echo $ngx_src \
- | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
+ | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
cat << END >> $NGX_MAKEFILE
@@ -242,10 +242,10 @@ if [ $HTTP = YES ]; then
do
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=`echo $ngx_src \
- | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
+ | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
cat << END >> $NGX_MAKEFILE
@@ -272,10 +272,10 @@ if [ $IMAP = YES ]; then
do
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=`echo $ngx_src \
- | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
+ | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
cat << END >> $NGX_MAKEFILE
@@ -302,10 +302,10 @@ if test -n "$NGX_ADDON_SRCS"; then
| sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=`echo $ngx_obj \
- | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
- -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
+ | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
diff --git a/auto/unix b/auto/unix
index 0fe29746c..1cf0dc3cd 100755
--- a/auto/unix
+++ b/auto/unix
@@ -21,7 +21,14 @@ ngx_param=NGX_PTR_SIZE; ngx_value=$ngx_size; . auto/types/value
# POSIX types
-NGX_INCLUDE_AUTO_CONFIG_H="#include \"../$NGX_AUTO_CONFIG_H\""
+case "$NGX_AUTO_CONFIG_H" in
+ /*)
+ NGX_INCLUDE_AUTO_CONFIG_H="#include \"$NGX_AUTO_CONFIG_H\""
+ ;;
+ *)
+ NGX_INCLUDE_AUTO_CONFIG_H="#include \"../$NGX_AUTO_CONFIG_H\""
+ ;;
+esac
ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 50746ae1e..1b135e596 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.53"
+#define NGINX_VER "nginx/0.3.54"
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ".oldbin"
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 7dc15623a..7d4cdbad6 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -1035,22 +1035,30 @@ ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
#if (NGX_DEBUG)
ngx_event_conf_t *ecf = conf;
- in_addr_t *addr;
- ngx_str_t *value;
- struct hostent *h;
+ ngx_event_debug_t *dc;
+ ngx_str_t *value;
+ struct hostent *h;
+ ngx_inet_cidr_t in_cidr;
value = cf->args->elts;
/* AF_INET only */
- addr = ngx_array_push(&ecf->debug_connection);
- if (addr == NULL) {
+ dc = ngx_array_push(&ecf->debug_connection);
+ if (dc == NULL) {
return NGX_CONF_ERROR;
}
- *addr = inet_addr((char *) value[1].data);
+ dc->addr = inet_addr((char *) value[1].data);
- if (*addr != INADDR_NONE) {
+ if (dc->addr != INADDR_NONE) {
+ dc->mask = 0xffffffff;
+ return NGX_OK;
+ }
+
+ if (ngx_ptocidr(&value[1], &in_cidr) == NGX_OK) {
+ dc->mask = in_cidr.mask;
+ dc->addr = in_cidr.addr;
return NGX_OK;
}
@@ -1062,7 +1070,8 @@ ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- *addr = *(in_addr_t *)(h->h_addr_list[0]);
+ dc->mask = 0xffffffff;
+ dc->addr = *(in_addr_t *)(h->h_addr_list[0]);
#else
@@ -1096,7 +1105,7 @@ ngx_event_create_conf(ngx_cycle_t *cycle)
#if (NGX_DEBUG)
if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4,
- sizeof(in_addr_t)) == NGX_ERROR)
+ sizeof(ngx_event_debug_t)) == NGX_ERROR)
{
return NGX_CONF_ERROR;
}
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 25f41896a..edcee4f10 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -189,6 +189,12 @@ struct ngx_event_s {
typedef struct {
+ in_addr_t mask;
+ in_addr_t addr;
+} ngx_event_debug_t;
+
+
+typedef struct {
ngx_int_t (*add)(ngx_event_t *ev, int event, u_int flags);
ngx_int_t (*del)(ngx_event_t *ev, int event, u_int flags);
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c
index e41f04ae5..efd09e1d9 100644
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -198,9 +198,6 @@ ngx_event_accept(ngx_event_t *ev)
wev->own_lock = &c->lock;
#endif
- ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
- "accept: fd:%d c:%d", s, c->number);
-
if (ls->addr_ntop) {
c->addr_text.data = ngx_palloc(c->pool, ls->addr_text_max_len);
if (c->addr_text.data == NULL) {
@@ -220,14 +217,14 @@ ngx_event_accept(ngx_event_t *ev)
#if (NGX_DEBUG)
{
- uint32_t *addr;
in_addr_t i;
+ ngx_event_debug_t *dc;
struct sockaddr_in *sin;
sin = (struct sockaddr_in *) sa;
- addr = ecf->debug_connection.elts;
+ dc = ecf->debug_connection.elts;
for (i = 0; i < ecf->debug_connection.nelts; i++) {
- if (addr[i] == sin->sin_addr.s_addr) {
+ if ((sin->sin_addr.s_addr & dc[i].mask) == dc[i].addr) {
log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL;
break;
}
@@ -236,6 +233,9 @@ ngx_event_accept(ngx_event_t *ev)
}
#endif
+ ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
+ "*%d accept: %V fd:%d", c->number, &c->addr_text, s);
+
if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) {
if (ngx_add_conn(c) == NGX_ERROR) {
ngx_close_accepted_connection(c);
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index 0bc31bca5..e3fdb6542 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -432,6 +432,17 @@ ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
b = cl->buf;
if (ngx_buf_size(b) == 0) {
+
+ *ll = ngx_alloc_chain_link(r->pool);
+ if (*ll == NULL) {
+ return NGX_ERROR;
+ }
+
+ (*ll)->buf = b;
+ (*ll)->next = NULL;
+
+ ll = &(*ll)->next;
+
continue;
}
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 172a1a74d..28f860e13 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -168,6 +168,7 @@ static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = {
{ ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 },
{ ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
{ ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
+ { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
{ ngx_null_string, 0 }
};
@@ -1694,6 +1695,11 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));
+ if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
+ conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
+ |NGX_HTTP_UPSTREAM_FT_OFF;
+ }
+
ngx_conf_merge_uint_value(conf->upstream.max_fails,
prev->upstream.max_fails, 1);
diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
index 000622d94..437369265 100644
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -45,6 +45,7 @@ static ngx_conf_bitmask_t ngx_http_memcached_next_upstream_masks[] = {
{ ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT },
{ ngx_string("invalid_response"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER },
{ ngx_string("not_found"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
+ { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
{ ngx_null_string, 0 }
};
@@ -560,6 +561,11 @@ ngx_http_memcached_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));
+ if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
+ conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
+ |NGX_HTTP_UPSTREAM_FT_OFF;
+ }
+
ngx_conf_merge_uint_value(conf->upstream.max_fails,
prev->upstream.max_fails, 1);
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index ff5b129a8..5999f2ed2 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -127,6 +127,7 @@ static ngx_conf_bitmask_t ngx_http_proxy_next_upstream_masks[] = {
{ ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 },
{ ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
{ ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
+ { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
{ ngx_null_string, 0 }
};
@@ -1648,6 +1649,11 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));
+ if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
+ conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
+ |NGX_HTTP_UPSTREAM_FT_OFF;
+ }
+
ngx_conf_merge_uint_value(conf->upstream.max_fails,
prev->upstream.max_fails, 1);
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index df758707f..867f8f7d8 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -19,8 +19,8 @@ typedef struct ngx_http_log_ctx_s ngx_http_log_ctx_t;
typedef ngx_int_t (*ngx_http_header_handler_pt)(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
-typedef u_char *(*ngx_http_log_handler_pt)(ngx_http_request_t *r, u_char *buf,
- size_t len);
+typedef u_char *(*ngx_http_log_handler_pt)(ngx_http_request_t *r,
+ ngx_http_request_t *sr, u_char *buf, size_t len);
#if (NGX_HTTP_CACHE)
@@ -49,6 +49,7 @@ typedef u_char *(*ngx_http_log_handler_pt)(ngx_http_request_t *r, u_char *buf,
struct ngx_http_log_ctx_s {
ngx_str_t *client;
ngx_http_request_t *request;
+ ngx_http_request_t *current_request;
};
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index b417f41c6..ee0d3ca92 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1162,6 +1162,7 @@ ngx_http_subrequest(ngx_http_request_t *r,
{
ngx_connection_t *c;
ngx_http_request_t *sr;
+ ngx_http_log_ctx_t *ctx;
ngx_http_core_srv_conf_t *cscf;
ngx_http_postponed_request_t *pr, *p;
@@ -1273,6 +1274,9 @@ ngx_http_subrequest(ngx_http_request_t *r,
r->postponed = pr;
}
+ ctx = c->log->data;
+ ctx->current_request = sr;
+
sr->internal = 1;
sr->fast_subrequest = 1;
diff --git a/src/http/ngx_http_postpone_filter_module.c b/src/http/ngx_http_postpone_filter_module.c
index b11774810..37d200c37 100644
--- a/src/http/ngx_http_postpone_filter_module.c
+++ b/src/http/ngx_http_postpone_filter_module.c
@@ -162,6 +162,7 @@ ngx_http_postpone_filter_output_postponed_request(ngx_http_request_t *r)
{
ngx_int_t rc;
ngx_chain_t *out;
+ ngx_http_log_ctx_t *ctx;
ngx_http_postponed_request_t *pr;
for ( ;; ) {
@@ -177,6 +178,9 @@ ngx_http_postpone_filter_output_postponed_request(ngx_http_request_t *r)
"http postpone filter handle \"%V?%V\"",
&pr->request->uri, &pr->request->args);
+ ctx = r->connection->log->data;
+ ctx->current_request = pr->request;
+
if (!pr->request->done) {
r->connection->data = pr->request;
return NGX_AGAIN;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index bf3b0edf8..0145fe7d4 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -43,8 +43,8 @@ static void ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error);
static void ngx_http_close_connection(ngx_connection_t *c);
static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len);
-static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, u_char *buf,
- size_t len);
+static u_char *ngx_http_log_error_handler(ngx_http_request_t *r,
+ ngx_http_request_t *sr, u_char *buf, size_t len);
#if (NGX_HTTP_SSL)
static void ngx_http_ssl_handshake(ngx_event_t *rev);
@@ -162,6 +162,7 @@ ngx_http_init_connection(ngx_connection_t *c)
ctx->client = &c->addr_text;
ctx->request = NULL;
+ ctx->current_request = NULL;
c->log->connection = c->number;
c->log->handler = ngx_http_log_error;
@@ -427,6 +428,7 @@ ngx_http_init_request(ngx_event_t *rev)
ctx = c->log->data;
ctx->request = r;
+ ctx->current_request = r;
r->log_handler = ngx_http_log_error_handler;
#if (NGX_STAT_STUB)
@@ -541,7 +543,6 @@ ngx_http_process_request_line(ngx_event_t *rev)
ngx_int_t rc, rv;
ngx_connection_t *c;
ngx_http_request_t *r;
- ngx_http_log_ctx_t *ctx;
c = rev->data;
r = c->data;
@@ -722,9 +723,6 @@ ngx_http_process_request_line(ngx_event_t *rev)
}
if (rv == NGX_DECLINED) {
- ctx = c->log->data;
- ctx->request = r;
-
r->request_line.len = r->header_in->end - r->request_start;
r->request_line.data = r->request_start;
@@ -1428,10 +1426,14 @@ ngx_http_request_handler(ngx_event_t *ev)
{
ngx_connection_t *c;
ngx_http_request_t *r;
+ ngx_http_log_ctx_t *ctx;
c = ev->data;
r = c->data;
+ ctx = c->log->data;
+ ctx->current_request = r;
+
if (ev->write) {
r->write_event_handler(r);
@@ -1445,6 +1447,7 @@ void
ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
{
ngx_http_request_t *pr;
+ ngx_http_log_ctx_t *ctx;
ngx_http_core_loc_conf_t *clcf;
if (rc == NGX_DONE) {
@@ -1523,6 +1526,9 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
r->connection->data = pr;
}
+ ctx = r->connection->log->data;
+ ctx->current_request = pr;
+
if (pr->postponed) {
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -2364,7 +2370,7 @@ ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len)
r = ctx->request;
if (r) {
- return r->log_handler(r, p, len);
+ return r->log_handler(r, ctx->current_request, p, len);
}
return p;
@@ -2372,9 +2378,12 @@ ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len)
static u_char *
-ngx_http_log_error_handler(ngx_http_request_t *r, u_char *buf, size_t len)
+ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr,
+ u_char *buf, size_t len)
{
- u_char *p;
+ u_char *p;
+ ngx_http_upstream_t *u;
+ ngx_peer_connection_t *peer;
if (r->server_name.data) {
p = ngx_snprintf(buf, len, ", server: %V", &r->server_name);
@@ -2406,6 +2415,26 @@ ngx_http_log_error_handler(ngx_http_request_t *r, u_char *buf, size_t len)
}
}
+ if (r != sr) {
+ p = ngx_snprintf(buf, len, ", subrequest: \"%V\"", &sr->uri);
+ len -= p - buf;
+ buf = p;
+ }
+
+ u = sr->upstream;
+
+ if (u) {
+ peer = &u->peer;
+
+ p = ngx_snprintf(buf, len, ", upstream: \"%V%V%s%V\"",
+ &u->conf->schema,
+ &peer->peers->peer[peer->cur_peer].name,
+ peer->peers->peer[peer->cur_peer].uri_separator,
+ &u->uri);
+ len -= p - buf;
+ buf = p;
+ }
+
return ngx_http_log_error_info(r, buf, len);
}
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index c6fa3fc09..5cc4d5225 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -92,7 +92,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
rb->bufs->buf = b;
rb->bufs->next = NULL;
- if (preread >= r->headers_in.content_length_n) {
+ if ((off_t) preread >= r->headers_in.content_length_n) {
/* the whole request body was pre-read */
@@ -120,7 +120,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
rb->rest = r->headers_in.content_length_n - preread;
- if (rb->rest <= (size_t) (b->end - b->last)) {
+ if (rb->rest <= (off_t) (b->end - b->last)) {
/* the whole request body may be placed in r->header_in */
@@ -242,7 +242,7 @@ ngx_http_do_read_client_request_body(ngx_http_request_t *r)
size = rb->buf->end - rb->buf->last;
- if (size > rb->rest) {
+ if ((off_t) size > rb->rest) {
size = (size_t) rb->rest;
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 782c14be9..5caad0052 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -78,9 +78,6 @@ static size_t ngx_http_upstream_log_response_time_getlen(ngx_http_request_t *r,
static u_char *ngx_http_upstream_log_response_time(ngx_http_request_t *r,
u_char *buf, ngx_http_log_op_t *op);
-static u_char *ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf,
- size_t len);
-
static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf);
static ngx_int_t ngx_http_upstream_status_variable(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
@@ -293,7 +290,6 @@ static ngx_http_variable_t ngx_http_upstream_vars[] = {
void
ngx_http_upstream_init(ngx_http_request_t *r)
{
- ngx_time_t *tp;
ngx_connection_t *c;
ngx_http_cleanup_t *cln;
ngx_http_upstream_t *u;
@@ -337,8 +333,6 @@ ngx_http_upstream_init(ngx_http_request_t *r)
}
u->peer.log = r->connection->log;
- u->saved_log_handler = r->log_handler;
- r->log_handler = ngx_http_upstream_log_error;
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
@@ -359,18 +353,6 @@ ngx_http_upstream_init(ngx_http_request_t *r)
return;
}
- u->state = ngx_array_push(&u->states);
- if (u->state == NULL) {
- ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return;
- }
-
- ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
-
- tp = ngx_timeofday();
-
- u->state->response_time = tp->sec * 1000 + tp->msec;
-
cln = ngx_http_cleanup_add(r, 0);
if (cln == NULL) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -528,12 +510,31 @@ static void
ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
{
ngx_int_t rc;
+ ngx_time_t *tp;
ngx_connection_t *c;
r->connection->log->action = "connecting to upstream";
r->connection->single_connection = 0;
+ if (u->state && u->state->response_time) {
+ tp = ngx_timeofday();
+ u->state->response_time = tp->sec * 1000 + tp->msec
+ - u->state->response_time;
+ }
+
+ u->state = ngx_array_push(&u->states);
+ if (u->state == NULL) {
+ ngx_http_upstream_finalize_request(r, u,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
+
+ tp = ngx_timeofday();
+ u->state->response_time = tp->sec * 1000 + tp->msec;
+
rc = ngx_event_connect_peer(&u->peer);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -761,15 +762,6 @@ ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u)
#endif
- /* add one more state */
-
- u->state = ngx_array_push(&u->states);
- if (u->state == NULL) {
- return NGX_ERROR;
- }
-
- ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
-
return NGX_OK;
}
@@ -1988,8 +1980,6 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r,
}
#endif
- r->log_handler = u->saved_log_handler;
-
if (rc == NGX_DECLINED) {
return;
}
@@ -2457,32 +2447,6 @@ ngx_http_upstream_log_response_time(ngx_http_request_t *r, u_char *buf,
}
-static u_char *
-ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len)
-{
- u_char *p;
- ngx_http_upstream_t *u;
- ngx_peer_connection_t *peer;
-
- u = r->upstream;
- peer = &u->peer;
-
- p = ngx_snprintf(buf, len,
- ", server: %V, URL: \"%V\","
- " upstream: \"%V%V%s%V\"",
- &r->server_name,
- &r->unparsed_uri,
- &u->conf->schema,
- &peer->peers->peer[peer->cur_peer].name,
- peer->peers->peer[peer->cur_peer].uri_separator,
- &u->uri);
- len -= p - buf;
- buf = p;
-
- return ngx_http_log_error_info(r, buf, len);
-}
-
-
static ngx_int_t
ngx_http_upstream_add_variables(ngx_conf_t *cf)
{
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 086d184b3..8c2a90193 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -16,14 +16,15 @@
#include <ngx_http.h>
-#define NGX_HTTP_UPSTREAM_FT_ERROR 0x002
-#define NGX_HTTP_UPSTREAM_FT_TIMEOUT 0x004
-#define NGX_HTTP_UPSTREAM_FT_INVALID_HEADER 0x008
-#define NGX_HTTP_UPSTREAM_FT_HTTP_500 0x010
-#define NGX_HTTP_UPSTREAM_FT_HTTP_503 0x020
-#define NGX_HTTP_UPSTREAM_FT_HTTP_404 0x040
-#define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x080
-#define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x100
+#define NGX_HTTP_UPSTREAM_FT_ERROR 0x00000002
+#define NGX_HTTP_UPSTREAM_FT_TIMEOUT 0x00000004
+#define NGX_HTTP_UPSTREAM_FT_INVALID_HEADER 0x00000008
+#define NGX_HTTP_UPSTREAM_FT_HTTP_500 0x00000010
+#define NGX_HTTP_UPSTREAM_FT_HTTP_503 0x00000020
+#define NGX_HTTP_UPSTREAM_FT_HTTP_404 0x00000040
+#define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00000080
+#define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00000100
+#define NGX_HTTP_UPSTREAM_FT_OFF 0x80000000
#define NGX_HTTP_UPSTREAM_INVALID_HEADER 40
@@ -193,8 +194,6 @@ struct ngx_http_upstream_s {
ngx_str_t method;
- ngx_http_log_handler_pt saved_log_handler;
-
ngx_http_upstream_state_t *state;
ngx_array_t states; /* of ngx_http_upstream_state_t */