]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: fd: add the tgid to the fd and pass it to fd_insert()
authorWilly Tarreau <w@1wt.eu>
Tue, 5 Jul 2022 03:16:13 +0000 (05:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 17:58:06 +0000 (19:58 +0200)
commit9464bb1f05b5e0046716b4573a567d3450ac7604
tree635f101df422b3a9f94b1f632668161198f3723c
parent512dd2dc1c17439f71dfa6fb9e020a009eb3d1c7
MEDIUM: fd: add the tgid to the fd and pass it to fd_insert()

The file descriptors will need to know the thread group ID in addition
to the mask. This extends fd_insert() to take the tgid, and will store
it into the FD.

In the FD, the tgid is stored as a combination of tgid on the lower 16
bits and a refcount on the higher 16 bits. This allows to know when it's
really possible to trust the tgid and the running mask. If a refcount is
higher than 1 it indeed indicates another thread else might be in the
process of updating these values.

Since a closed FD must necessarily have a zero refcount, a test was
added to fd_insert() to make sure that it is the case.
include/haproxy/fd-t.h
include/haproxy/fd.h
src/dns.c
src/fd.c
src/proto_sockpair.c
src/sock.c
src/sock_inet.c
src/sock_unix.c
src/ssl_sock.c