From 5d68858ba78f485e19e2c36b15f86c8cc8435ff9 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 20 Aug 2021 19:15:26 +0300 Subject: QLocalSocket/Win: fix waitFor...() functions for write-only socket There were several issues with the socket state checking when the pipe reader is not running: - the number of object handles in the WaitForMultipleObjectsEx() call might have been zero; - a call to the waitForDisconnected(-1) might have hung; - we did not perform a loop iteration for the waitFor...(0) calls, so disconnect detection was unreliable. These issues are related to the same code, so they don't seem to be addressable separately. Change-Id: I3bca872bb4191e6a7d38a693d81f7981af7fe145 Reviewed-by: Oswald Buddenhagen --- tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto/network/socket') diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 97214a5914..f537bd9157 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -1479,6 +1479,13 @@ void tst_QLocalSocket::writeOnlySocket() QCOMPARE(client.bytesAvailable(), qint64(0)); QCOMPARE(client.state(), QLocalSocket::ConnectedState); + + serverSocket->abort(); + // On Windows, we need to test that the socket state is periodically + // checked in a loop, even if no timeout value is specified (i.e. + // waitForDisconnected(-1) does not fail immediately). + QVERIFY(client.waitForDisconnected(-1)); + QCOMPARE(client.state(), QLocalSocket::UnconnectedState); } void tst_QLocalSocket::writeToClientAndDisconnect_data() -- cgit v1.2.3