MINOR: thread: only use atomic ops to touch the flags
The thread flags are touched a little bit by other threads, e.g. the STUCK
flag may be set by other ones, and they're watched a little bit. As such
we need to use atomic ops only to manipulate them. Most places were already
using them, but here we generalize the practice. Only ha_thread_dump() does
not change because it's run under isolation.
diff --git a/src/debug.c b/src/debug.c
index a55d087..4207d13 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -154,6 +154,7 @@
* The calling thread ID needs to be passed in <calling_tid> to display a star
* in front of the calling thread's line (usually it's tid). Any stuck thread
* is also prefixed with a '>'.
+ * It must be called under thread isolation.
*/
void ha_thread_dump(struct buffer *buf, int thr, int calling_tid)
{
@@ -1365,7 +1366,7 @@
* if it didn't move.
*/
if (!((threads_harmless_mask|sleeping_thread_mask) & tid_bit))
- th_ctx->flags |= TH_FL_STUCK;
+ _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_STUCK);
}
static int init_debug_per_thread()