diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-08-20 19:15:26 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-09-02 08:47:11 +0300 |
commit | 5d68858ba78f485e19e2c36b15f86c8cc8435ff9 (patch) | |
tree | 997ed53bc0360239a684daeb9fdab838325d13fe /tests/auto/network | |
parent | 9a4c98e55659b32db984612e6247ac193812a502 (diff) |
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 <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'tests/auto/network')
-rw-r--r-- | tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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() |