aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-07-11 13:20:19 +0000
committerIgor Sysoev <igor@sysoev.ru>2006-07-11 13:20:19 +0000
commitbb28b6d3a455c20077a7e2d7319c24e484694a72 (patch)
tree32b623670825037be2ec50a8082176d9173a917a /src/http/ngx_http_request.c
parent09e1981c04aa20858f63ee2eeff588ca3827282b (diff)
downloadnginx-release-0.3.54.tar.gz
nginx-release-0.3.54.zip
nginx-0.3.54-RELEASE importrelease-0.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; the bug had appeared in 0.3.53.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c47
1 files changed, 38 insertions, 9 deletions
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);
}