From d44f1fb14cbdae099fcf7dafd0d247a4555a02bc Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 2 Jul 2019 12:02:08 +0200 Subject: Check sysconf errors Close #418 (#420) --- cpp/src/Ice/ThreadPool.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cpp/src/Ice/ThreadPool.cpp') diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index b836137170a..7d95c48b2b5 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -273,8 +273,20 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); int nProcessors = sysInfo.dwNumberOfProcessors; +# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + static int ncpu[2] = { CTL_HW, HW_NCPU }; + size_t sz = sizeof(nProcessors); + int nProcessors; + if(sysctl(ncpu, 2, &nProcessors, &sz, 0, 0) == -1) + { + nProcessors = 1; + } # else int nProcessors = static_cast(sysconf(_SC_NPROCESSORS_ONLN)); + if(nProcessors == -1) + { + nProcessors = 1; + } # endif #endif -- cgit v1.2.3