From 70c7206bff02c9d99aade564c818d8afab4de859 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Mon, 4 Jul 2016 20:23:17 +0200 Subject: [PATCH] pulsecore: Use _SC_NPROCESSORS_ONLN instead of _SC_NPROCESSORS_CONF pa_ncpu() is supposed to report the number of processors available on the system. For that, it currently calls sysconf(_SC_NPROCESSORS_CONF). However, since the operating system can disable individual processors, we should call sysconf(_SC_NPROCESSORS_ONLN) to determine the number of processors currently available. Consequently, the once-test will fail since pthread_setaffinity_np() is called with CPUs that are currently not available. See: https://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html Signed-off-by: John Paul Adrian Glaubitz --- src/pulsecore/core-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index f816da9..f648af8 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -3179,8 +3179,8 @@ void pa_reduce(unsigned *num, unsigned *den) { unsigned pa_ncpus(void) { long ncpus; -#ifdef _SC_NPROCESSORS_CONF - ncpus = sysconf(_SC_NPROCESSORS_CONF); +#ifdef _SC_NPROCESSORS_ONLN + ncpus = sysconf(_SC_NPROCESSORS_ONLN); #else ncpus = 1; #endif -- 2.8.1