BUG/MEDIUM: fd: don't wait for tmask to stabilize if we're not in it.
authorOlivier Houchard <cognet@ci0.org>
Thu, 13 Apr 2023 14:12:38 +0000 (16:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Apr 2023 16:04:46 +0000 (18:04 +0200)
commitf98a8c317e9b13ae7e1d154c13ba8ca1dd6b4ce4
tree66b0935941670e5a303cb1db15cfdad86b11da1c
parenta07635ead593371a74f0e63aad756916677221b2
BUG/MEDIUM: fd: don't wait for tmask to stabilize if we're not in it.

In fd_update_events(), we loop until there's no bit in the running_mask
that is not in the thread_mask. Problem is, the thread sets its
running_mask bit before that loop, and so if 2 threads do the same, and
a 3rd one just closes the FD and sets the thread_mask to 0, then
running_mask will always be non-zero, and we will loop forever. This is
trivial to reproduce when using a DNS resolver that will just answer
"port unreachable", but could theoretically happen with other types of
file descriptors too.

To fix that, just don't bother looping if we're no longer in the
thread_mask, if that happens we know we won't have to take care of the
FD, anyway.

This should be backported to 2.7, 2.6 and 2.5.
src/fd.c