From: David CARLIER Date: Fri, 15 Jan 2021 08:09:56 +0000 (+0000) Subject: BUG/MINOR: threads: Fixes the number of possible cpus report for Mac. X-Git-Tag: v2.1.12~71 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=edb98bd09e7e400674436e49c83aab223e58a512;p=haproxy-2.1.git BUG/MINOR: threads: Fixes the number of possible cpus report for Mac. There is no low level api to achieve same as Linux/FreeBSD, we rely on CPUs available. Without this, the number of threads is just 1 for Mac while having 8 cores in my M1. Backporting to 2.1 should be enough if that's possible. Signed-off-by: David CARLIER (cherry picked from commit 6a9060189d66ca931984706d5e2a970ed913f457) Signed-off-by: Christopher Faulet (cherry picked from commit 64e563351414f6bdcc9e9f8bc41a13c496ff8ecc) Signed-off-by: Christopher Faulet (cherry picked from commit c84718cab39b69ba743d927bf3d641bd3ff53fa3) Signed-off-by: Christopher Faulet --- diff --git a/src/hathreads.c b/src/hathreads.c index ec0edb6..33685bc 100644 --- a/src/hathreads.c +++ b/src/hathreads.c @@ -182,6 +182,8 @@ static int thread_cpus_enabled() if (cpuset_getaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, sizeof(cpuset), &cpuset) == 0) ret = CPU_COUNT(&cpuset); +#elif defined(__APPLE__) + ret = (int)sysconf(_SC_NPROCESSORS_ONLN); #endif #endif ret = MAX(ret, 1);