mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-23 15:19:36 -04:00
MINOR: poller: update_fd_polling: wake a random other thread
When enabling an FD that's only bound to another thread, instead of always picking the first one, let's pick a random one. This is rarely used (enabling a frontend, or session rate-limiting period ending), and has greater chances of avoiding that some obscure corner cases could degenerate into a poorly distributed load.
This commit is contained in:
parent
962e5ba72b
commit
555c192d14
1 changed files with 5 additions and 3 deletions
8
src/fd.c
8
src/fd.c
|
|
@ -449,9 +449,11 @@ 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)) {
|
||||
/* 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;
|
||||
|
||||
/* we need to wake up another thread to handle it immediately, any will fit,
|
||||
* so let's pick a random one so that it doesn't always end up on the same.
|
||||
*/
|
||||
int thr = one_among_mask(fdtab[fd].thread_mask & all_threads_mask,
|
||||
statistical_prng_range(MAX_THREADS));
|
||||
wake_thread(thr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue