]> git.kaiwu.me - nginx.git/commitdiff
Cache: proper wakeup of subrequests.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 2 Dec 2014 02:54:56 +0000 (05:54 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 2 Dec 2014 02:54:56 +0000 (05:54 +0300)
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.)

src/http/ngx_http_file_cache.c

index af0423ad240c5db3f1d2323e5833f32c311d753c..c3f4f05d2d41a467958dcd5ab334cd27b6610650 100644 (file)
@@ -462,6 +462,8 @@ ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev)
                    "http file cache wait: \"%V?%V\"", &r->uri, &r->args);
 
     ngx_http_file_cache_lock_wait(r, r->cache);
+
+    ngx_http_run_posted_requests(c);
 }
 
 
@@ -505,7 +507,7 @@ wakeup:
 
     c->waiting = 0;
     r->main->blocked--;
-    r->connection->write->handler(r->connection->write);
+    r->write_event_handler(r);
 }
 
 
@@ -692,7 +694,9 @@ ngx_http_cache_aio_event_handler(ngx_event_t *ev)
     r->main->blocked--;
     r->aio = 0;
 
-    r->connection->write->handler(r->connection->write);
+    r->write_event_handler(r);
+
+    ngx_http_run_posted_requests(c);
 }
 
 #endif