BUG/MEDIUM: threads: Fiw build when using no thread
Some checks are pending
Contrib / admin/halog/ (push) Waiting to run
Contrib / dev/flags/ (push) Waiting to run
Contrib / dev/haring/ (push) Waiting to run
Contrib / dev/hpack/ (push) Waiting to run
Contrib / dev/poll/ (push) Waiting to run
FreeBSD / clang (push) Waiting to run
VTest / Generate Build Matrix (push) Waiting to run
VTest / (push) Blocked by required conditions
Windows / Windows, gcc, all features (push) Waiting to run

In thread_detect_count(), avoid any usage of thread_cpu_enable_at_boot
if we're building without thread support. That variable is only defined
when building with threads, and those tests make little sense when
building with no thread, anyway.
This was submitted by: ririnto <ririnto@kakao.com>
This should fix github issue #3408.
This should be backported to 3.4.
This commit is contained in:
Olivier Houchard 2026-06-08 02:07:03 +02:00 committed by Olivier Houchard
parent ac776e3819
commit 45a64123d6

View file

@ -1667,7 +1667,9 @@ void thread_detect_count(void)
char *err __maybe_unused;
int thr_forced = 0;
int tgrp_forced = 0;
#ifdef USE_THREAD
int cpus_detected = 0;
#endif
thr_min = 1; thr_max = MAX_THREADS;
grp_min = 1; grp_max = MAX_TGROUPS;
@ -1810,6 +1812,7 @@ void thread_detect_count(void)
if (!global.nbtgroups)
global.nbtgroups = grp_min;
#ifdef USE_THREAD
if (tgrp_forced && !thr_forced && !cpu_map_in_conf &&
(!global.thread_limit || (global.nbthread < global.thread_limit)) &&
global.nbthread < MIN(cpus_detected, thread_cpus_enabled_at_boot) &&
@ -1828,6 +1831,7 @@ void thread_detect_count(void)
ha_notice("%d usable CPUs detected but 'nbthread' forced to %d (%d%%). Remove 'nbthread' for optimal tuning.\n",
nbcpus, global.nbthread, global.nbthread * 100 / nbcpus);
}
#endif
if (global.nbthread > global.maxthrpertgroup * global.nbtgroups) {
ha_diag_warning("nbthread too large or not set, found %d CPUs, limiting to %d threads (maximum is %d per thread group and %d groups). Please set nbthreads and/or increase thread-groups in the global section to silence this warning.\n",