]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: fd: Mark a fd as dead on early close
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 13 Nov 2026 14:39:34 +0000 (15:39 +0100)
committerOlivier Houchard <cognet@ci0.org>
Fri, 13 Nov 2026 14:30:15 +0000 (15:30 +0100)
commit3fe45b94cfda16cc495335ee8fd66a50fc89d808
tree4a7ba97008e7030f3ce66f90377f84a44df59702
parent2cd73b0826ee71a07a245649330ab15e5d9bc929
BUG/MEDIUM: fd: Mark a fd as dead on early close

Commit ad082111a04b4387f8aa76e386a2f340f9583bd2 made it so
conn_ctrl_close() will close a fd, if no xprt was created, because
nobody else would do it for us. But this is not entirely true, some code
paths, such as the checks, if connection failed, will take care of
closing the fd already, and doing it in conn_ctrl_close() will lead to a
second close, that may close an unrelated fd.
Fix that by changing the fd to DEAD_FD_MAGIC so that conn_ctrl_close()
knows the fd has already been closed, and don't have to do it.
It would probably be cleaner to just remove those calls to close(), and
always let conn_ctrl_close() do it, but for that we'd have to make sure
conn_ctrl_close() is always called, and that close to the release, I'd
rather go the safer way.

This should be backported to all supported versions, when
ad082111a04b4387f8aa76e386a2f340f9583bd2 has been backported already.

This should fix github issue #3573.
src/proto_sockpair.c
src/proto_tcp.c
src/proto_uxst.c