summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthread_p.h
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2013-03-15 19:48:59 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-23 02:06:47 +0100
commitd4adee7851790dd6949424de083756f49af891db (patch)
tree00416d4afc19fd37ce6f3a121d842ee0914ad5e7 /src/corelib/thread/qthread_p.h
parentc550a5d42c1188c0ccd11c205665e2608dbec61f (diff)
Fix race condition in QThread::setPriority
The value of priority was read without the mutex locked, from within the thread. Had to extract a QThreadPrivate::setPriority method so that it can be called with the mutex already locked. So if the main thread calls setPriority while the thread is starting, it will be either be before or after the "re-set priority" code at thread startup, but at least not in the middle of it. Change-Id: I7a054f68623f61482c749274da66f3b2dcd8bcee Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/thread/qthread_p.h')
-rw-r--r--src/corelib/thread/qthread_p.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 7e963fdcd1..9d773b3c1c 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -142,6 +142,8 @@ public:
QThreadPrivate(QThreadData *d = 0);
~QThreadPrivate();
+ void setPriority(QThread::Priority prio);
+
mutable QMutex mutex;
QAtomicInt quitLockRef;