From: Willy Tarreau Date: Thu, 23 Jun 2022 16:38:06 +0000 (+0200) Subject: MEDIUM: polling: make update_fd_polling() not care about sleeping threads X-Git-Tag: v2.7-dev2~134 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=962e5ba72bc500d7d6e263c43a43da2069391214;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/fd.c b/src/fd.c index 5dd648ef7e..426afb5a63 100644 --- 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;