]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd: make fd_clr_running() return the remaining running mask
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Mar 2021 09:27:56 +0000 (10:27 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Mar 2021 16:17:21 +0000 (17:17 +0100)
We'll need to know that a thread is the last one to use an fd, so let's
make fd_clr_running() return the remaining bits after removal. Note that
in practice we're only interested in knowing if it's zero but the compiler
doesn't make use of the clags after the AND and emits a CMPXCHG anyway :-/

This will need to be backported to 2.2 to fix an issue.

include/haproxy/fd.h

index 20e4d754fad1a9701213b50cdc90a293a07f816b..69eda485f5cb5fbe09636dca681360c9152ce6ae 100644 (file)
@@ -347,10 +347,12 @@ static inline void fd_set_running_excl(int fd)
                old_mask = 0;
 }
 
-
-static inline void fd_clr_running(int fd)
+/* remove tid_bit from the fd's running mask and returns the bits that remain
+ * after the atomic operation.
+ */
+static inline long fd_clr_running(int fd)
 {
-       _HA_ATOMIC_AND(&fdtab[fd].running_mask, ~tid_bit);
+       return _HA_ATOMIC_AND(&fdtab[fd].running_mask, ~tid_bit);
 }
 
 /* Update events seen for FD <fd> and its state if needed. This should be