]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: tcp: make tcp_connect_probe() consider ERR/HUP
authorWilly Tarreau <w@1wt.eu>
Fri, 27 Dec 2019 09:25:29 +0000 (10:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 Dec 2019 15:38:04 +0000 (16:38 +0100)
commit7deff246ce98ece3f331c203861e70c9ee4340da
tree3da9db157f1e5154ebdb543566d9967f9a5589b4
parent11ef0837afe9c00600152dfdf5c4f73ab2bf293f
MEDIUM: tcp: make tcp_connect_probe() consider ERR/HUP

Now that we know what pollers can return ERR/HUP, we can take this
into account to save one syscall: with such a poller, if neither are
reported, then we know the connection succeeded and we don't need to
go with getsockopt() nor connect() to validate this. In addition, for
the remaining cases (select() or suspected errors), we'll always go
through the extra connect() attempt and enumerate possible "in progress",
"connected" or "failed" status codes and take action solely based on
this.

This results in one saved syscall on modern pollers, only a second
connect() still being used on select() and the server's address never
being needed anymore.

Note that we cannot safely replace connect() with getsockopt() as the
latter clears the error on the socket without saving it, and health
checks rely on it for their reporting. This would be OK if the error
was saved in the connection itself.
src/proto_tcp.c