[BUG] fix truncated responses with sepoll
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2008 16:20:13 +0000 (17:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2008 16:20:13 +0000 (17:20 +0100)
commitd6f087ea1ce589fb38817e9d81f37795a6bb70c5
tree1f0e4ff585b9a0cd11105d6f7de8f35c4945dc87
parentb881608e5794bbde4d2da8bc5b3e10a2b32686e4
[BUG] fix truncated responses with sepoll

Due to the way Linux delivers EPOLLIN and EPOLLHUP, a closed connection
received after some server data sometimes results in truncated responses
if the client disconnects before server starts to respond. The reason
is that the EPOLLHUP flag is processed as an indication of end of
transfer while some data may remain in the system's socket buffers.

This problem could only be triggered with sepoll, although nothing should
prevent it from happening with normal epoll. In fact, the work factoring
performed by sepoll increases the risk that this bug appears.

The fix consists in making FD_POLL_HUP and FD_POLL_ERR sticky and that
they are only checked if FD_POLL_IN is not set, meaning that we have
read all pending data.

That way, the problem is definitely fixed and sepoll still remains about
17% faster than epoll since it can take into account all information
returned by the kernel.
include/proto/fd.h
include/types/fd.h
src/checks.c
src/client.c
src/ev_sepoll.c
src/proto_tcp.c
src/proto_uxst.c
src/stream_sock.c