From 124b9a6ff89da8be83a256135ec6c4d0603e9a6f Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 21 Jan 2017 18:09:11 +0200 Subject: Improve suppression of spurious socket notifications under Windows There were still two cases where spurious notifications would be possible: - user calls hasPendingDatagrams()/pendingDatagramSize() on UDP socket somewhere outside the slot connected to readyRead() signal (::WSARecvFrom posts FD_READ notification, even if a notification for incoming datagram already exists in the message queue); - a socket was registered to receive several types of event and WM_QT_ACTIVATENOTIFIERS message is located between the different events for this socket in the queue. Provided patch ensures that the message queue is synchronized with the Qt event processing mechanism and adds a way to detect spurious notifications inside the window procedure. Task-number: QTBUG-58214 Change-Id: I49609dace601f300de09875ff1653617efabd72f Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll Reviewed-by: Oliver Wolff Reviewed-by: Edward Welbourne Reviewed-by: Peter Seiderer --- tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index 1598382959..a52b80170f 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -360,11 +360,16 @@ void tst_QSocketNotifier::asyncMultipleDatagram() QSignalSpy spy(m_asyncReceiver, &QIODevice::readyRead); connect(m_asyncReceiver, &QIODevice::readyRead, this, &tst_QSocketNotifier::async_readDatagramSlot); + + // activate socket notifiers + QTestEventLoop::instance().enterLoopMSecs(100); + m_asyncSender->writeDatagram("1", makeNonAny(m_asyncReceiver->localAddress()), port); m_asyncSender->writeDatagram("2", makeNonAny(m_asyncReceiver->localAddress()), port); // wait a little to ensure that the datagrams we've just sent // will be delivered on receiver side. QTest::qSleep(100); + QVERIFY(m_asyncReceiver->hasPendingDatagrams()); QTimer::singleShot(500, this, &tst_QSocketNotifier::async_writeDatagramSlot); -- cgit v1.2.3