Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 6950:4cb4ffe06785
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 28 Mar 2017 18:15:41 +0300 |
parents | fbdaad9b0e7b |
children | 903fb1ddc07f |
comparison
equal
deleted
inserted
replaced
6949:ff0c8e11edbc | 6950:4cb4ffe06785 |
---|---|
3734 "http upstream thread: \"%V?%V\"", &r->uri, &r->args); | 3734 "http upstream thread: \"%V?%V\"", &r->uri, &r->args); |
3735 | 3735 |
3736 r->main->blocked--; | 3736 r->main->blocked--; |
3737 r->aio = 0; | 3737 r->aio = 0; |
3738 | 3738 |
3739 r->write_event_handler(r); | 3739 if (r->done) { |
3740 | 3740 /* |
3741 ngx_http_run_posted_requests(c); | 3741 * trigger connection event handler if the subrequest was |
3742 * already finalized; this can happen if the handler is used | |
3743 * for sendfile() in threads | |
3744 */ | |
3745 | |
3746 c->write->handler(c->write); | |
3747 | |
3748 } else { | |
3749 r->write_event_handler(r); | |
3750 ngx_http_run_posted_requests(c); | |
3751 } | |
3742 } | 3752 } |
3743 | 3753 |
3744 #endif | 3754 #endif |
3745 | 3755 |
3746 | 3756 |