diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-16 16:22:10 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-20 01:39:22 +0100 |
commit | 80d0075588aa94e011a394967fb21d8bb0c84781 (patch) | |
tree | fa43764ab19cec005c3535d78d29fbf8f0191da3 /src/corelib | |
parent | 1c1cce67fa1d03a49cdfb6f1ca378b182925ffdb (diff) |
Fix QThread::idealThreadCount on Unix if sysconf or sysctl fails
The BSD4 code (including OS X) calls sysctl and if that fails, it sets
cores to -1. Similarly, the generic Unix code calls sysconf() and
assigns the returned value to cores, but sysconf can return -1 on
failure.
Change-Id: I9e521d366e9c42f36c2ba20a37e7a74539ddb8f4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 5df50311ef..9a14503584 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -450,7 +450,8 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW // the rest: Linux, Solaris, AIX, Tru64 cores = (int)sysconf(_SC_NPROCESSORS_ONLN); #endif - + if (cores == -1) + return 1; return cores; } |