diff options
author | Liang Qi <liang.qi@qt.io> | 2017-11-30 08:28:20 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-11-30 09:16:58 +0100 |
commit | 87204c856ae3d8495c41af998ac196a12fe1c779 (patch) | |
tree | 5af64eaa3acde506d19fe4ab1c88b028a2197adf /src/corelib/thread | |
parent | 498ef7f9d77fca75bcba2f657aaac38c8dc78aea (diff) | |
parent | d0812cbdabcff4d388334c499c23992cce98d4da (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
src/corelib/thread/qsemaphore.cpp
tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
Change-Id: Id35b535e88df63fdfe4007ea92ed4a39c4b6d707
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qsemaphore.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 21acc533a1..012628ef63 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -414,13 +414,18 @@ bool QSemaphore::tryAcquire(int n) bool QSemaphore::tryAcquire(int n, int timeout) { Q_ASSERT_X(n >= 0, "QSemaphore::tryAcquire", "parameter 'n' must be non-negative"); + + // We're documented to accept any negative value as "forever" + // but QDeadlineTimer only accepts -1. + timeout = qMax(timeout, -1); + if (futexAvailable()) - return futexSemaphoreTryAcquire<true>(u, n, timeout < 0 ? -1 : timeout); + return futexSemaphoreTryAcquire<true>(u, n, timeout); QDeadlineTimer timer(timeout); QMutexLocker locker(&d->mutex); qint64 remainingTime = timer.remainingTime(); - while (n > d->avail && remainingTime > 0) { + while (n > d->avail && remainingTime != 0) { if (!d->cond.wait(locker.mutex(), remainingTime)) return false; remainingTime = timer.remainingTime(); |