diff --git a/src/haproxy.c b/src/haproxy.c index 3cf57e4a4..3c7828535 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3020,6 +3020,9 @@ static void *run_thread_poll_loop(void *data) ha_set_thread(data); set_thread_cpu_affinity(); clock_set_local_source(); + /* thread is started, from now on it is not idle nor harmless */ + thread_harmless_end(); + thread_idle_end(); /* Now, initialize one thread init at a time. This is better since * some init code is a bit tricky and may release global resources diff --git a/src/thread.c b/src/thread.c index 00d9f9fba..241377ec6 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1199,6 +1199,16 @@ int thread_map_to_groups() m = 0; for (g = 0; g < global.nbtgroups; g++) { ha_tgroup_info[g].threads_enabled = nbits(ha_tgroup_info[g].count); + /* for now, additional threads are not started, so we should + * consider them as harmless and idle. + * This will get automatically updated when such threads are + * started in run_thread_poll_loop() + * Without this, thread_isolate() and thread_isolate_full() + * will fail to work as long as secondary threads did not enter + * the polling loop at least once. + */ + ha_tgroup_ctx[g].threads_harmless = ha_tgroup_info[g].threads_enabled; + ha_tgroup_ctx[g].threads_idle = ha_tgroup_info[g].threads_enabled; if (!ha_tgroup_info[g].count) continue; m |= 1UL << g;