diff options
author | Jose <pepone@users.noreply.github.com> | 2019-07-02 12:02:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-02 12:02:08 +0200 |
commit | d44f1fb14cbdae099fcf7dafd0d247a4555a02bc (patch) | |
tree | 29c7a1b86b6a5944097318ed2b8cd2ea9137b9dc /cpp/src/Ice | |
parent | Wait 60s for the process controller to start (needed for Android) (diff) | |
download | ice-d44f1fb14cbdae099fcf7dafd0d247a4555a02bc.tar.bz2 ice-d44f1fb14cbdae099fcf7dafd0d247a4555a02bc.tar.xz ice-d44f1fb14cbdae099fcf7dafd0d247a4555a02bc.zip |
Check sysconf errors Close #418 (#420)
Diffstat (limited to 'cpp/src/Ice')
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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<int>(sysconf(_SC_NPROCESSORS_ONLN)); + if(nProcessors == -1) + { + nProcessors = 1; + } # endif #endif |