MEDIUM: polling: make update_fd_polling() not care about sleeping threads

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.
This commit is contained in:
Willy Tarreau 2022-06-23 18:38:06 +02:00
parent 058b2c1015
commit 962e5ba72b

View File

@ -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;