]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: polling: make update_fd_polling() not care about sleeping threads
authorWilly Tarreau <w@1wt.eu>
Thu, 23 Jun 2022 16:38:06 +0000 (18:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Jul 2022 17:15:14 +0000 (19:15 +0200)
Till now, update_fd_polling() used to check if all the target threads were
sleeping, and only then would wake an owning thread up. This causes several
problems among which the need for the sleeping_thread_mask and the fact that
by the time we wake one thread up, it has changed.

This commit changes this by leaving it to wake_thread() to perform this
check on the selected thread, since wake_thread() is already capable of
doing this now. Concretely speaking, for updt_fd_polling() it will mean
performing one computation of an ffsl() before knowing the sleeping status
on a global FD state change (which is very rare and not important here,
as it basically happens after relaxing a rate-limit (i.e. once a second
at beast) or after enabling a frontend from the CLI); thus we don't care.

src/fd.c

index 5dd648ef7effd1eb9dc37a7c42502dd9b6cd9706..426afb5a63e135c859f000a3d156007d8454e18c 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -448,9 +448,7 @@ void updt_fd_polling(const int fd)
 
                fd_add_to_fd_list(&update_list, fd, offsetof(struct fdtab, update));
 
-               if (fd_active(fd) &&
-                   !(fdtab[fd].thread_mask & tid_bit) &&
-                   (fdtab[fd].thread_mask & ~tid_bit & all_threads_mask & ~sleeping_thread_mask) == 0) {
+               if (fd_active(fd) && !(fdtab[fd].thread_mask & tid_bit)) {
                        /* we need to wake up one thread to handle it immediately */
                        int thr = my_ffsl(fdtab[fd].thread_mask & ~tid_bit & all_threads_mask) - 1;