diff --git a/include/haproxy/tinfo-t.h b/include/haproxy/tinfo-t.h index 45cfe8a29..a12e0a4b7 100644 --- a/include/haproxy/tinfo-t.h +++ b/include/haproxy/tinfo-t.h @@ -60,6 +60,8 @@ enum { #define TH_FL_TASK_PROFILING 0x00000002 #define TH_FL_NOTIFIED 0x00000004 /* task was notified about the need to wake up */ #define TH_FL_SLEEPING 0x00000008 /* thread won't check its task list before next wakeup */ +#define TH_FL_STARTED 0x00000010 /* set once the thread starts */ +#define TH_FL_IN_LOOP 0x00000020 /* set only inside the polling loop */ /* Thread group information. This defines a base and a count of global thread diff --git a/src/haproxy.c b/src/haproxy.c index 09e4198d7..fe612b0c1 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2922,6 +2922,8 @@ void run_poll_loop() { int next, wake; + _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_IN_LOOP); + clock_update_date(0,1); while (1) { wake_expired_tasks(); @@ -3010,6 +3012,8 @@ void run_poll_loop() activity[tid].loops++; } + + _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_LOOP); } static void *run_thread_poll_loop(void *data) @@ -3028,6 +3032,7 @@ static void *run_thread_poll_loop(void *data) /* thread is started, from now on it is not idle nor harmless */ thread_harmless_end(); thread_idle_end(); + _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_STARTED); /* Now, initialize one thread init at a time. This is better since * some init code is a bit tricky and may release global resources