]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: tasks/fd: replace sleeping_thread_mask with a TH_FL_SLEEPING flag
authorWilly Tarreau <w@1wt.eu>
Mon, 20 Jun 2022 07:23:24 +0000 (09:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Jul 2022 17:15:14 +0000 (19:15 +0200)
commite7475c8e793f335bb61c2db4eedc30416321b9e2
tree66d3da05593483328337960982452738daad1874
parentdce4ad755f0cfac80b9f51ff06fcf0c7387b8693
MEDIUM: tasks/fd: replace sleeping_thread_mask with a TH_FL_SLEEPING flag

Every single place where sleeping_thread_mask was still used was to test
or set a single thread. We can now add a per-thread flag to indicate a
thread is sleeping, and remove this shared mask.

The wake_thread() function now always performs an atomic fetch-and-or
instead of a first load then an atomic OR. That's cleaner and more
reliable.

This is not easy to test, as broadcast FD events are rare. The good
way to test for this is to run a very low rate-limited frontend with
a listener that listens to the fewest possible threads (2), and to
send it only 1 connection at a time. The listener will periodically
pause and the wakeup task will sometimes wake up on a random thread
and will call wake_thread():

   frontend test
        bind :8888 maxconn 10 thread 1-2
        rate-limit sessions 5

Alternately, disabling/enabling a frontend in loops via the CLI also
broadcasts such events, but they're more difficult to observe since
this is causing connection failures.
include/haproxy/fd.h
include/haproxy/global.h
include/haproxy/tinfo-t.h
src/debug.c
src/fd.c
src/haproxy.c
src/wdt.c