MINOR: threads: add flags to know if a thread is started and/or running
authorWilly Tarreau <w@1wt.eu>
Fri, 17 Feb 2023 07:36:42 +0000 (08:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 17 Feb 2023 15:01:34 +0000 (16:01 +0100)
commit3e820a105699ad0c52ce6984293a16e53fd7b6a9
tree1943203461ce765465fe650a3e339b1f71b3f80f
parentba4c7a15978deaf74b6af09d2a13b4fff7ccea74
MINOR: threads: add flags to know if a thread is started and/or running

Several times during debugging it has been difficult to find a way to
reliably indicate if a thread had been started and if it was still
running. It's really not easy because the elements we look at are not
necessarily reliable (e.g. harmless bit or idle bit might not reflect
what we think during a signal). And such notions can be subjective
anyway.

Here we define two thread flags, TH_FL_STARTED which is set as soon as
a thread enters run_thread_poll_loop() and drops the idle bit, and
another one, TH_FL_IN_LOOP, which is set when entering run_poll_loop()
and cleared when leaving it. This should help init/deinit code know
whether it's called from a non-initialized thread (i.e. tid must not
be trusted), or shared functions know if they're being called from a
running thread or from init/deinit code outside of the polling loop.
include/haproxy/tinfo-t.h
src/haproxy.c