comparison src/http/ngx_http_file_cache.c @ 5929:f436e9a60b8f

Cache: proper wakeup of subrequests. In case of a cache lock timeout and in the aio handler we now call r->write_event_handler() instead of a connection write handler, to make sure to run appropriate subrequest. Previous code failed to run inactive subrequests and hence resulted in suboptimal behaviour, see report by Yichun Zhang: http://mailman.nginx.org/pipermail/nginx-devel/2013-October/004435.html (Infinite hang claimed in the report seems impossible without 3rd party modules, as subrequests will be eventually woken up by the postpone filter.)
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 02 Dec 2014 05:54:56 +0300
parents 8dfee01ff0bd
children 1573fc7875fa
comparison
equal deleted inserted replaced
5928:8dfee01ff0bd 5929:f436e9a60b8f
460 460
461 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, 461 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
462 "http file cache wait: \"%V?%V\"", &r->uri, &r->args); 462 "http file cache wait: \"%V?%V\"", &r->uri, &r->args);
463 463
464 ngx_http_file_cache_lock_wait(r, r->cache); 464 ngx_http_file_cache_lock_wait(r, r->cache);
465
466 ngx_http_run_posted_requests(c);
465 } 467 }
466 468
467 469
468 static void 470 static void
469 ngx_http_file_cache_lock_wait(ngx_http_request_t *r, ngx_http_cache_t *c) 471 ngx_http_file_cache_lock_wait(ngx_http_request_t *r, ngx_http_cache_t *c)
503 505
504 wakeup: 506 wakeup:
505 507
506 c->waiting = 0; 508 c->waiting = 0;
507 r->main->blocked--; 509 r->main->blocked--;
508 r->connection->write->handler(r->connection->write); 510 r->write_event_handler(r);
509 } 511 }
510 512
511 513
512 static ngx_int_t 514 static ngx_int_t
513 ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c) 515 ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c)
690 "http file cache aio: \"%V?%V\"", &r->uri, &r->args); 692 "http file cache aio: \"%V?%V\"", &r->uri, &r->args);
691 693
692 r->main->blocked--; 694 r->main->blocked--;
693 r->aio = 0; 695 r->aio = 0;
694 696
695 r->connection->write->handler(r->connection->write); 697 r->write_event_handler(r);
698
699 ngx_http_run_posted_requests(c);
696 } 700 }
697 701
698 #endif 702 #endif
699 703
700 704