summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-07-09 03:04:20 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2019-07-11 14:29:08 +0200
commit335f1d02dc134bf11277c0573553c7c838cc6a9f (patch)
treed313e015e24aadef9ee147e27dd16094b770712a /src
parent0d3fb431458109918785b90e1c5bd2d42b586fa6 (diff)
parentb24e07cbcbf7d7846baaaab77d632a2422128ada (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13"
Diffstat (limited to 'src')
-rw-r--r--src/serialport/qwinoverlappedionotifier.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/serialport/qwinoverlappedionotifier.cpp b/src/serialport/qwinoverlappedionotifier.cpp
index 615dacc9..233ee696 100644
--- a/src/serialport/qwinoverlappedionotifier.cpp
+++ b/src/serialport/qwinoverlappedionotifier.cpp
@@ -129,6 +129,7 @@ public:
HANDLE hSemaphore = nullptr;
HANDLE hResultsMutex = nullptr;
QAtomicInt waiting;
+ QAtomicInt pendingNotifications;
QQueue<IOResult> results;
};
@@ -395,14 +396,17 @@ void QWinOverlappedIoNotifierPrivate::notify(DWORD numberOfBytes, DWORD errorCod
results.enqueue(IOResult(numberOfBytes, errorCode, overlapped));
ReleaseMutex(hResultsMutex);
ReleaseSemaphore(hSemaphore, 1, NULL);
- if (!waiting)
+ if (!waiting && pendingNotifications-- == 0)
emit q->_q_notify();
}
void QWinOverlappedIoNotifierPrivate::_q_notified()
{
- if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
- dispatchNextIoResult();
+ int n = pendingNotifications.fetchAndStoreAcquire(0);
+ while (--n >= 0) {
+ if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
+ dispatchNextIoResult();
+ }
}
OVERLAPPED *QWinOverlappedIoNotifierPrivate::dispatchNextIoResult()