Mercurial > hg > nginx-quic
comparison src/http/ngx_http_file_cache.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 | 2f7e557eab5b |
children | f436e9a60b8f |
comparison
equal
deleted
inserted
replaced
5927:ac2a8e4d8f01 | 5928:8dfee01ff0bd |
---|---|
12 | 12 |
13 | 13 |
14 static ngx_int_t ngx_http_file_cache_lock(ngx_http_request_t *r, | 14 static ngx_int_t ngx_http_file_cache_lock(ngx_http_request_t *r, |
15 ngx_http_cache_t *c); | 15 ngx_http_cache_t *c); |
16 static void ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev); | 16 static void ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev); |
17 static void ngx_http_file_cache_lock_wait(ngx_http_request_t *r, | |
18 ngx_http_cache_t *c); | |
17 static ngx_int_t ngx_http_file_cache_read(ngx_http_request_t *r, | 19 static ngx_int_t ngx_http_file_cache_read(ngx_http_request_t *r, |
18 ngx_http_cache_t *c); | 20 ngx_http_cache_t *c); |
19 static ssize_t ngx_http_file_cache_aio_read(ngx_http_request_t *r, | 21 static ssize_t ngx_http_file_cache_aio_read(ngx_http_request_t *r, |
20 ngx_http_cache_t *c); | 22 ngx_http_cache_t *c); |
21 #if (NGX_HAVE_FILE_AIO) | 23 #if (NGX_HAVE_FILE_AIO) |
446 | 448 |
447 | 449 |
448 static void | 450 static void |
449 ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev) | 451 ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev) |
450 { | 452 { |
451 ngx_uint_t wait; | 453 ngx_connection_t *c; |
452 ngx_msec_t now, timer; | 454 ngx_http_request_t *r; |
453 ngx_http_cache_t *c; | |
454 ngx_http_request_t *r; | |
455 ngx_http_file_cache_t *cache; | |
456 | 455 |
457 r = ev->data; | 456 r = ev->data; |
458 c = r->cache; | 457 c = r->connection; |
458 | |
459 ngx_http_set_log_request(c->log, r); | |
460 | |
461 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
462 "http file cache wait: \"%V?%V\"", &r->uri, &r->args); | |
463 | |
464 ngx_http_file_cache_lock_wait(r, r->cache); | |
465 } | |
466 | |
467 | |
468 static void | |
469 ngx_http_file_cache_lock_wait(ngx_http_request_t *r, ngx_http_cache_t *c) | |
470 { | |
471 ngx_uint_t wait; | |
472 ngx_msec_t now, timer; | |
473 ngx_http_file_cache_t *cache; | |
459 | 474 |
460 now = ngx_current_msec; | 475 now = ngx_current_msec; |
461 | 476 |
462 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ev->log, 0, | |
463 "http file cache wait handler wt:%M cur:%M", | |
464 c->wait_time, now); | |
465 | |
466 timer = c->wait_time - now; | 477 timer = c->wait_time - now; |
467 | 478 |
468 if ((ngx_msec_int_t) timer <= 0) { | 479 if ((ngx_msec_int_t) timer <= 0) { |
469 ngx_log_error(NGX_LOG_INFO, ev->log, 0, "cache lock timeout"); | 480 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
481 "cache lock timeout"); | |
470 c->lock_timeout = 0; | 482 c->lock_timeout = 0; |
471 goto wakeup; | 483 goto wakeup; |
472 } | 484 } |
473 | 485 |
474 cache = c->file_cache; | 486 cache = c->file_cache; |
483 } | 495 } |
484 | 496 |
485 ngx_shmtx_unlock(&cache->shpool->mutex); | 497 ngx_shmtx_unlock(&cache->shpool->mutex); |
486 | 498 |
487 if (wait) { | 499 if (wait) { |
488 ngx_add_timer(ev, (timer > 500) ? 500 : timer); | 500 ngx_add_timer(&c->wait_event, (timer > 500) ? 500 : timer); |
489 return; | 501 return; |
490 } | 502 } |
491 | 503 |
492 wakeup: | 504 wakeup: |
493 | 505 |
663 | 675 |
664 static void | 676 static void |
665 ngx_http_cache_aio_event_handler(ngx_event_t *ev) | 677 ngx_http_cache_aio_event_handler(ngx_event_t *ev) |
666 { | 678 { |
667 ngx_event_aio_t *aio; | 679 ngx_event_aio_t *aio; |
680 ngx_connection_t *c; | |
668 ngx_http_request_t *r; | 681 ngx_http_request_t *r; |
669 | 682 |
670 aio = ev->data; | 683 aio = ev->data; |
671 r = aio->data; | 684 r = aio->data; |
685 c = r->connection; | |
686 | |
687 ngx_http_set_log_request(c->log, r); | |
688 | |
689 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
690 "http file cache aio: \"%V?%V\"", &r->uri, &r->args); | |
672 | 691 |
673 r->main->blocked--; | 692 r->main->blocked--; |
674 r->aio = 0; | 693 r->aio = 0; |
675 | 694 |
676 r->connection->write->handler(r->connection->write); | 695 r->connection->write->handler(r->connection->write); |