Mercurial > hg > nginx
comparison src/event/modules/ngx_epoll_module.c @ 6440:248aa2757332
Fixed timeouts with threaded sendfile() and subrequests.
If a write event happens after sendfile() but before we've got the
sendfile results in the main thread, this write event will be ignored.
And if no more events will happen, the connection will hang.
Removing the events works in the simple cases, but not always, as
in some cases events are added back by an unrelated code. E.g.,
the upstream module adds write event in the ngx_http_upstream_init()
to track client aborts.
Fix is to use wev->complete instead. It is now set to 0 before
a sendfile() task is posted, and it is set to 1 once a write event
happens. If on completion of the sendfile() task wev->complete is 1,
we know that an event happened while we were executing sendfile(), and
the socket is still ready for writing even if sendfile() did not sent
all the data or returned EAGAIN.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 18 Mar 2016 05:04:45 +0300 |
parents | d0a84ae2fb48 |
children | f01ab2dbcfdc |
comparison
equal
deleted
inserted
replaced
6439:81329f6a4254 | 6440:248aa2757332 |
---|---|
838 "epoll: stale event %p", c); | 838 "epoll: stale event %p", c); |
839 continue; | 839 continue; |
840 } | 840 } |
841 | 841 |
842 wev->ready = 1; | 842 wev->ready = 1; |
843 #if (NGX_THREADS) | |
844 wev->complete = 1; | |
845 #endif | |
843 | 846 |
844 if (flags & NGX_POST_EVENTS) { | 847 if (flags & NGX_POST_EVENTS) { |
845 ngx_post_event(wev, &ngx_posted_events); | 848 ngx_post_event(wev, &ngx_posted_events); |
846 | 849 |
847 } else { | 850 } else { |