comparison src/http/ngx_http_upstream.c @ 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 1d0e03db9f8e
children 3c87b82b17d4
comparison
equal deleted inserted replaced
6535:db699978a33f 6536:f7849bfb6d21
1220 1220
1221 #endif 1221 #endif
1222 1222
1223 #if (NGX_HAVE_EPOLLRDHUP) 1223 #if (NGX_HAVE_EPOLLRDHUP)
1224 1224
1225 if ((ngx_event_flags & NGX_USE_EPOLL_EVENT) && ev->pending_eof) { 1225 if ((ngx_event_flags & NGX_USE_EPOLL_EVENT) && ngx_use_epoll_rdhup) {
1226 socklen_t len; 1226 socklen_t len;
1227
1228 if (!ev->pending_eof) {
1229 return;
1230 }
1227 1231
1228 ev->eof = 1; 1232 ev->eof = 1;
1229 c->error = 1; 1233 c->error = 1;
1230 1234
1231 err = 0; 1235 err = 0;