summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-02-02 10:31:20 (GMT)
committerSamuli Piippo <samuli.piippo@digia.com>2011-06-09 10:07:10 (GMT)
commitd6a9d6adde4ee478b6b7664590ef2fe4e1410db8 (patch)
tree84c7bb267329882526ba88647b081652e3dd816c /src
parent037144a9cb4c7674322e63f9d93fe10561332b58 (diff)
downloadQt-d6a9d6adde4ee478b6b7664590ef2fe4e1410db8.zip
Qt-d6a9d6adde4ee478b6b7664590ef2fe4e1410db8.tar.gz
Qt-d6a9d6adde4ee478b6b7664590ef2fe4e1410db8.tar.bz2
Fix QMutex can deadlock when calling tryLock
in the unix code, if the QMutexPrivate::wait() with a timeout expires in the same moment that the mutex is released, wakeup would be set, but would be then ignored. (reset to false quickly after) If we waken up between the timeout and the re-aquisition of the internal mutex, we consider that the mutex has been locked. Reviewed-by: brad Task-number: QTBUG-16115 (cherry picked from commit 7987d4cfd3ce86c20a55b5661a5221f12246b27e)
Diffstat (limited to 'src')
-rw-r--r--src/corelib/thread/qmutex_unix.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp
index b04fd67..4eb9750 100644
--- a/src/corelib/thread/qmutex_unix.cpp
+++ b/src/corelib/thread/qmutex_unix.cpp
@@ -94,8 +94,11 @@ bool QMutexPrivate::wait(int timeout)
errorCode = pthread_cond_timedwait(&cond, &mutex, &ti);
}
if (errorCode) {
- if (errorCode == ETIMEDOUT)
+ if (errorCode == ETIMEDOUT) {
+ if (wakeup)
+ errorCode = 0;
break;
+ }
report_error(errorCode, "QMutex::lock()", "cv wait");
}
}