mirror of
https://github.com/nginx/nginx.git
synced 2025-01-19 01:42:58 +08:00
Threads: fixed request hang with aio_write and subrequests.
If the subrequest is already finalized, the handler set with aio_write may still be used by sendfile in threads when using range requests (see also e4c1f5b32868, and the original note in 9fd738b85fad). Calling already finalized subrequest's r->write_event_handler in practice results in request hang in some cases. Fix is to trigger connection event handler if the subrequest was already finalized.
This commit is contained in:
parent
ff33d9fa55
commit
a450865b5a
@ -3736,9 +3736,19 @@ ngx_http_upstream_thread_event_handler(ngx_event_t *ev)
|
||||
r->main->blocked--;
|
||||
r->aio = 0;
|
||||
|
||||
r->write_event_handler(r);
|
||||
if (r->done) {
|
||||
/*
|
||||
* trigger connection event handler if the subrequest was
|
||||
* already finalized; this can happen if the handler is used
|
||||
* for sendfile() in threads
|
||||
*/
|
||||
|
||||
ngx_http_run_posted_requests(c);
|
||||
c->write->handler(c->write);
|
||||
|
||||
} else {
|
||||
r->write_event_handler(r);
|
||||
ngx_http_run_posted_requests(c);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user