]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: fd: pass the iocb and owner to fd_insert()
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Jan 2018 06:22:13 +0000 (07:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 29 Jan 2018 15:07:25 +0000 (16:07 +0100)
commita9786b6f043774f66f23d40cc0cb6317b433bbb3
tree82deb50b4a92e7d8ea3d6aa6e69d5cc765487d1c
parentfc6eea4de24fbefa24115fb0b51f629b742da1e2
MINOR: fd: pass the iocb and owner to fd_insert()

fd_insert() is currently called just after setting the owner and iocb,
but proceeding like this prevents the operation from being atomic and
requires a lock to protect the maxfd computation in another thread from
meeting an incompletely initialized FD and computing a wrong maxfd.
Fortunately for now all fdtab[].owner are set before calling fd_insert(),
and the first lock in fd_insert() enforces a memory barrier so the code
is safe.

This patch moves the initialization of the owner and iocb to fd_insert()
so that the function will be able to properly arrange its operations and
remain safe even when modified to become lockless. There's no other change
beyond the internal API.
include/proto/connection.h
include/proto/fd.h
src/dns.c
src/haproxy.c
src/hathreads.c
src/proto_tcp.c
src/proto_uxst.c
src/ssl_sock.c