QThreadPool: fix race on 'queue' in stealRunnable()
authorMarc Mutz <marc.mutz@kdab.com>
Fri, 17 Aug 2012 08:57:15 +0000 (10:57 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 17 Aug 2012 14:28:01 +0000 (16:28 +0200)
The code under mutex protection already implicitly handles the case where
queue.empty(), so just removing the pre-lock check suffices.

Change-Id: I01467aff62e61bb4efd16359dd64546ff51c6bad
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/corelib/thread/qthreadpool.cpp

index a923b8a..1c3672b 100644 (file)
@@ -314,7 +314,7 @@ bool QThreadPoolPrivate::waitForDone(int msecs)
 */
 void QThreadPoolPrivate::stealRunnable(QRunnable *runnable)
 {
-    if (runnable == 0 || queue.isEmpty())
+    if (runnable == 0)
         return;
     bool found = false;
     {