comparison src/http/ngx_http_request.c @ 5928:8dfee01ff0bd

Upstream: improved subrequest logging. To ensure proper logging make sure to set current_request in all event handlers, including resolve, ssl handshake, cache lock wait timer and aio read handlers. A macro ngx_http_set_log_request() introduced to simplify this.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 02 Dec 2014 05:54:54 +0300
parents 21043ce2a005
children 5b549cc7f698
comparison
equal deleted inserted replaced
5927:ac2a8e4d8f01 5928:8dfee01ff0bd
2167 static void 2167 static void
2168 ngx_http_request_handler(ngx_event_t *ev) 2168 ngx_http_request_handler(ngx_event_t *ev)
2169 { 2169 {
2170 ngx_connection_t *c; 2170 ngx_connection_t *c;
2171 ngx_http_request_t *r; 2171 ngx_http_request_t *r;
2172 ngx_http_log_ctx_t *ctx;
2173 2172
2174 c = ev->data; 2173 c = ev->data;
2175 r = c->data; 2174 r = c->data;
2176 2175
2177 ctx = c->log->data; 2176 ngx_http_set_log_request(c->log, r);
2178 ctx->current_request = r;
2179 2177
2180 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, 2178 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
2181 "http run request: \"%V?%V\"", &r->uri, &r->args); 2179 "http run request: \"%V?%V\"", &r->uri, &r->args);
2182 2180
2183 if (ev->write) { 2181 if (ev->write) {
2193 2191
2194 void 2192 void
2195 ngx_http_run_posted_requests(ngx_connection_t *c) 2193 ngx_http_run_posted_requests(ngx_connection_t *c)
2196 { 2194 {
2197 ngx_http_request_t *r; 2195 ngx_http_request_t *r;
2198 ngx_http_log_ctx_t *ctx;
2199 ngx_http_posted_request_t *pr; 2196 ngx_http_posted_request_t *pr;
2200 2197
2201 for ( ;; ) { 2198 for ( ;; ) {
2202 2199
2203 if (c->destroyed) { 2200 if (c->destroyed) {
2213 2210
2214 r->main->posted_requests = pr->next; 2211 r->main->posted_requests = pr->next;
2215 2212
2216 r = pr->request; 2213 r = pr->request;
2217 2214
2218 ctx = c->log->data; 2215 ngx_http_set_log_request(c->log, r);
2219 ctx->current_request = r;
2220 2216
2221 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, 2217 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
2222 "http posted request: \"%V?%V\"", &r->uri, &r->args); 2218 "http posted request: \"%V?%V\"", &r->uri, &r->args);
2223 2219
2224 r->write_event_handler(r); 2220 r->write_event_handler(r);