]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: sock: handle a weird condition with connect()
authorWilly Tarreau <w@1wt.eu>
Tue, 9 Apr 2024 06:03:10 +0000 (08:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Apr 2024 15:04:25 +0000 (17:04 +0200)
commitb4734c2bd7981846142ecabe3490bbf356993b08
tree7ba085fb5a3e0610d396aabbd1adcad34c55c3bf
parentfbc0850d36fddec8055bc3b52b0e343ef90b0f9f
BUG/MINOR: sock: handle a weird condition with connect()

As reported on github issue #2491, there's a very strange situation where
epoll_wait() appears to be reported EPOLLERR only (and not IN/OUT/HUP etc
as normally happens with EPOLLERR), and when connect() is called again to
check the state of the ongoing connection, it returns EALREADY, basically
saying "no news, please wait". This obviously triggers a wakeup loop. For
now it has remained impossible to reproduce this issue outside of the
reporter's environment, but that's definitely something that is impossible
to get out from.

The workaround here is to address the lowest level cause we can act on,
which is to avoid returning to wait if EPOLLERR was returned. Indeed, in
this case we know it will loop, so we must definitely take this one into
account. We only do that after connect() asks us to wait, so that a
properly established connection with a queued error at the end of an
exchange will not be diverted and will be handled as usual.

This should be backported to approximately all versions, at least as far
as 2.4 according to the reporter who observed it there.

Thanks to @donnyxray for their useful captures isolating the problem.
src/sock.c