]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: proto_tcp: make the pause() more robust in multi-process
authorWilly Tarreau <w@1wt.eu>
Thu, 8 Oct 2020 14:51:09 +0000 (16:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Oct 2020 09:27:30 +0000 (11:27 +0200)
commit91c614dd0eedfa7b14c490bbc0f5886cc4290826
tree10f03cdc304afcbf19b905afd0b3a2a2b64106e6
parent1accacbcc31212d1ac742cda1f9d8429398a21ab
MEDIUM: proto_tcp: make the pause() more robust in multi-process

In multi-process, the TCP pause is very brittle and we never noticed
it because the error was lost in the upper layers. The problem is that
shutdown() may fail if another process already did it, and will cause
a process to fail to pause.

What we do here in case of error is that we double-check the socket's
state to verify if it's still accepting connections, and if not, we
can conclude that another process already did the job in parallel.

The difficulty here is that we're trying to eliminate false positives
where some OSes will silently report a success on shutdown() while they
don't shut the socket down, hence this dance of shutw/listen/shutr that
only keeps the compatible ones. Probably that a new approach relying on
connect(AF_UNSPEC) would provide better results.
src/proto_tcp.c