Mercurial > hg > nginx
comparison src/event/ngx_event.h @ 6536:f7849bfb6d21
Improved EPOLLRDHUP handling.
When it's known that the kernel supports EPOLLRDHUP, there is no need in
additional recv() call to get EOF or error when the flag is absent in the
event generated by the kernel. A special runtime test is done at startup
to detect if EPOLLRDHUP is actually supported by the kernel because
epoll_ctl() silently ignores unknown flags.
With this knowledge it's now possible to drop the "ready" flag for partial
read. Previously, the "ready" flag was kept until the recv() returned EOF
or error. In particular, this change allows the lingering close heuristics
(which relies on the "ready" flag state) to actually work on Linux, and not
wait for more data in most cases.
The "available" flag is now used in the read event with the semantics similar
to the corresponding counter in kqueue.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 13 May 2016 17:19:23 +0300 |
parents | 2cd019520210 |
children | bcd442b585f0 |
comparison
equal
deleted
inserted
replaced
6535:db699978a33f | 6536:f7849bfb6d21 |
---|---|
94 * read: bytes to read when event is ready | 94 * read: bytes to read when event is ready |
95 * or lowat when event is set with NGX_LOWAT_EVENT flag | 95 * or lowat when event is set with NGX_LOWAT_EVENT flag |
96 * write: available space in buffer when event is ready | 96 * write: available space in buffer when event is ready |
97 * or lowat when event is set with NGX_LOWAT_EVENT flag | 97 * or lowat when event is set with NGX_LOWAT_EVENT flag |
98 * | 98 * |
99 * epoll with EPOLLRDHUP: | |
100 * accept: 1 if accept many, 0 otherwise | |
101 * read: 1 if there can be data to read, 0 otherwise | |
102 * | |
99 * iocp: TODO | 103 * iocp: TODO |
100 * | 104 * |
101 * otherwise: | 105 * otherwise: |
102 * accept: 1 if accept many, 0 otherwise | 106 * accept: 1 if accept many, 0 otherwise |
103 */ | 107 */ |
194 void (*done)(ngx_cycle_t *cycle); | 198 void (*done)(ngx_cycle_t *cycle); |
195 } ngx_event_actions_t; | 199 } ngx_event_actions_t; |
196 | 200 |
197 | 201 |
198 extern ngx_event_actions_t ngx_event_actions; | 202 extern ngx_event_actions_t ngx_event_actions; |
203 #if (NGX_HAVE_EPOLLRDHUP) | |
204 extern ngx_uint_t ngx_use_epoll_rdhup; | |
205 #endif | |
199 | 206 |
200 | 207 |
201 /* | 208 /* |
202 * The event filter requires to read/write the whole data: | 209 * The event filter requires to read/write the whole data: |
203 * select, poll, /dev/poll, kqueue, epoll. | 210 * select, poll, /dev/poll, kqueue, epoll. |