From 80d0075588aa94e011a394967fb21d8bb0c84781 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 16 Dec 2014 16:22:10 -0800 Subject: 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 --- src/corelib/thread/qthread_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/thread') 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; } -- cgit v1.2.3