From 90838f676a57d8afbc9926d84408b14311269801 Mon Sep 17 00:00:00 2001 From: CallMeFoxie Date: Fri, 22 Sep 2023 10:54:51 +0200 Subject: [PATCH] Correctly detect CPU cores when cpuset cgroup is used --- client/hostinfo_unix.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index cec9401f5f7..358a8a3d814 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -1334,6 +1334,12 @@ int HOST_INFO::get_cpu_count() { if(cpus_sys_path > p_ncpus){ p_ncpus = cpus_sys_path; } +#elif __GNU_LIBRARY__ /* glibc */ + cpu_set_t set; + + if (sched_getaffinity (0, sizeof (set), &set) == 0) { + p_ncpus = CPU_COUNT (&set); + } #elif defined(_SC_NPROCESSORS_ONLN) && !defined(__EMX__) && !defined(__APPLE__) // sysconf not working on OS2 p_ncpus = sysconf(_SC_NPROCESSORS_ONLN);