MINOR: sock: implement sock_accept_conn() to accept a connection
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Oct 2020 07:21:31 +0000 (09:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 15 Oct 2020 19:47:56 +0000 (21:47 +0200)
commitf1dc9f2f175c94c0a0109d8d3a4f9f14a30a47b0
tree1273c7d13bc7780f84ed34190b66ddf1922109cb
parent1e509a7231ad70ce18760962decbe46b38b8872a
MINOR: sock: implement sock_accept_conn() to accept a connection

The socket-specific accept() code in listener_accept() has nothing to
do there. Let's move it to sock.c where it can be significantly cleaned
up. It will now directly return an accepted connection and provide a
status code instead of letting listener_accept() deal with various errno
values. Note that this doesn't support the sockpair specific code.

The function is now responsible for dealing with its own receiver's
polling state and calling fd_cant_recv() when facing EAGAIN.

One tiny change from the previous implementation is that the connection's
sockaddr is now allocated before trying accept(), which saves a memcpy()
of the resulting address for each accept at the expense of a cheap
pool_alloc/pool_free on the final accept returning EAGAIN. This still
apparently slightly improves accept performance in microbencharks.
include/haproxy/sock.h
src/proto_tcp.c
src/proto_uxst.c
src/sock.c