MINOR: fd: make fd_clr_running() return the previous value instead
It's an AND so it destroys information and due to this there's a call
place where we have to perform two reads to know the previous value
then to change it. With a fetch-and-and instead, in a single operation
we can know if the bit was previously present, which is more efficient.
diff --git a/src/fd.c b/src/fd.c
index 5782349..56a7711 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -378,7 +378,7 @@
HA_ATOMIC_OR(&fdtab[fd].running_mask, ti->ltid_bit);
HA_ATOMIC_STORE(&fdtab[fd].thread_mask, 0);
- if (fd_clr_running(fd) == 0)
+ if (fd_clr_running(fd) == ti->ltid_bit)
_fd_delete_orphan(fd);
}
@@ -594,8 +594,7 @@
* This is detected by both thread_mask and running_mask being 0 after
* we remove ourselves last.
*/
- if ((fdtab[fd].running_mask & ti->ltid_bit) &&
- fd_clr_running(fd) == 0 && !fdtab[fd].thread_mask) {
+ if (fd_clr_running(fd) == ti->ltid_bit && !fdtab[fd].thread_mask) {
_fd_delete_orphan(fd);
return FD_UPDT_CLOSED;
}