nginx-0.3.54-RELEASE import

*) 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; the bug had
       appeared in 0.3.53.
This commit is contained in:
Igor Sysoev 2006-07-11 13:20:19 +00:00
parent 09e1981c04
commit bb28b6d3a4
18 changed files with 236 additions and 117 deletions

View File

@ -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"`

View File

@ -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

View File

@ -9,6 +9,73 @@
<title lang="en">nginx changelog</title>
<changes ver="0.3.54" date="11.07.2006">
<change type="feature">
<para lang="ru">
nginx ÔÅÐÅÒØ ÚÁÐÉÓÙ×ÁÅÔ × ÌÏÇ ÉÎÆÏÒÍÁÃÉÀ Ï ÐÏÄÚÁÐÒÏÓÁÈ.
</para>
<para lang="en">
nginx now logs the subrequest information to the error log.
</para>
</change>
<change type="feature">
<para lang="ru">
ÄÉÒÅËÔÉ×Ù proxy_next_upstream, fastcgi_next_upstream É memcached_next_upstream
ÐÏÄÄÅÒÖÉ×ÁÀÔ ÐÁÒÁÍÅÔÒ off.
</para>
<para lang="en">
the "proxy_next_upstream", "fastcgi_next_upstream",
and "memcached_next_upstream" directives support the "off" parameter.
</para>
</change>
<change type="feature">
<para lang="ru">
ÄÉÒÅËÔÉ×Á debug_connection ÐÏÄÄÅÒÖÉ×ÁÅÔ ÚÁÐÉÓØ ÁÄÒÅÓÏ× × ÆÏÒÍÁÔÅ CIDR.
</para>
<para lang="en">
the "debug_connection" directive supports the CIDR address form.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÐÒÉ ÐÅÒÅËÏÄÉÒÏ×ÁÎÉÉ ÏÔ×ÅÔÁ ÐÒÏËÓÉÒÏ×ÁÎÎÏÇÏ ÓÅÒ×ÅÒÁ ÉÌÉ ÓÅÒ×ÅÒÁ FastCGI
× UTF-8 ÉÌÉ ÎÁÏÂÏÒÏÔ ÏÔ×ÅÔ ÍÏÇ ÐÅÒÅÄÁ×ÁÔØÓÑ ÎÅ ÐÏÌÎÏÓÔØÀ.
</para>
<para lang="en">
if a response of proxied server or FastCGI server was converted from UTF-8
or back, then it may be transferred incomplete.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÐÅÒÅÍÅÎÎÁÑ $upstream_response_time ÓÏÄÅÒÖÁÌÁ ×ÒÅÍÑ ÔÏÌØËÏ ÐÅÒ×ÏÇÏ
ÏÂÒÁÝÅÎÉÑ Ë ÂÜËÅÎÄÕ.
</para>
<para lang="en">
the $upstream_response_time variable had the time of the first
request to a backend only.
</para>
</change>
<change type="bugfix">
<para lang="ru">
nginx ÎÅ ÓÏÂÉÒÁÌÓÑ ÎÁ ÐÌÁÔÆÏÒÍÅ amd64;
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.3.53.
</para>
<para lang="en">
nginx could not be built on amd64 platform;
bug appeared in 0.3.53.
</para>
</change>
</changes>
<changes ver="0.3.53" date="07.07.2006">
<change type="change">
@ -55,7 +122,7 @@ nginx supports the request body size more than 2G.
</para>
<para lang="en">
if a client was successfully authorized using "satisfy_any on", then anyway
the "access forbidden by rule" message was written in the log.
the message "access forbidden by rule" was written in the log.
</para>
</change>

View File

@ -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"

View File

@ -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;
}

View File

@ -188,6 +188,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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
};

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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 */