mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-21 14:35:45 +00:00
MINOR: debug: mark oneself harmless while waiting for threads to finish
The debug_handler() function waits for other threads to join, but does not mark itself as harmless, so if at the same time another thread tries to isolate, this may deadlock. In practice this does not happen as the signal is received during epoll_wait() hence under harmless mode, but it can possibly arrive under other conditions. In order to improve this, while waiting for other threads to join, we're now marking the current thread as harmless, as it's doing nothing but waiting for the other ones. This way another harmless waiter will be able to proceed. It's valid to do this since we're not doing anything else in this loop. One improvement could be to also check for the thread being idle and marking it idle in addition to harmless, so that it can even release a full isolation requester. But that really doesn't look worth it.
This commit is contained in:
parent
a2b8ed4b44
commit
f7afdd910b
13
src/debug.c
13
src/debug.c
@ -1340,9 +1340,15 @@ void debug_handler(int sig, siginfo_t *si, void *arg)
|
||||
*/
|
||||
|
||||
/* wait for all previous threads to finish first */
|
||||
if (!harmless)
|
||||
thread_harmless_now();
|
||||
|
||||
while (threads_to_dump & (tid_bit - 1))
|
||||
ha_thread_relax();
|
||||
|
||||
if (!harmless)
|
||||
thread_harmless_end();
|
||||
|
||||
/* dump if needed */
|
||||
if (threads_to_dump & tid_bit) {
|
||||
if (thread_dump_buffer)
|
||||
@ -1361,8 +1367,15 @@ void debug_handler(int sig, siginfo_t *si, void *arg)
|
||||
* present again. This way the threads_to_dump variable never passes to
|
||||
* zero until all visitors have stopped waiting.
|
||||
*/
|
||||
if (!harmless)
|
||||
thread_harmless_now();
|
||||
|
||||
while (!(threads_to_dump & tid_bit))
|
||||
ha_thread_relax();
|
||||
|
||||
if (!harmless)
|
||||
thread_harmless_end();
|
||||
|
||||
HA_ATOMIC_AND(&threads_to_dump, ~tid_bit);
|
||||
|
||||
/* mark the current thread as stuck to detect it upon next invocation
|
||||
|
Loading…
Reference in New Issue
Block a user