diff options
author | Joerg Bornemann <joerg.bornemann@nokia.com> | 2010-06-10 11:10:27 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@nokia.com> | 2010-06-10 13:31:18 (GMT) |
commit | 12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f (patch) | |
tree | e4ec8b700782701d7601d7d039f4b53b60cbe7a8 /tests/auto/qlocalsocket | |
parent | cbe3425a3bd226c61c94f92c521dc5c9b090ef96 (diff) | |
download | Qt-12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f.zip Qt-12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f.tar.gz Qt-12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f.tar.bz2 |
QLocalSocket: fix reading from a socket after broken connection
Reading from a socket with a broken connection didn't work, even if
there were still bytes to read in the internal read buffer.
Autotest: tst_QLocalSocket::writeToClientAndDisconnect
Task-number: QTBUG-10921
Reviewed-by: ossi
Diffstat (limited to 'tests/auto/qlocalsocket')
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index dbb58c1..87a30c2 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -980,6 +980,7 @@ void tst_QLocalSocket::writeToClientAndDisconnect() QLocalServer server; QLocalSocket client; + QSignalSpy readChannelFinishedSpy(&client, SIGNAL(readChannelFinished())); QVERIFY(server.listen("writeAndDisconnectServer")); client.connectToServer("writeAndDisconnectServer"); @@ -992,10 +993,19 @@ void tst_QLocalSocket::writeToClientAndDisconnect() memset(buffer, 0, sizeof(buffer)); QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); clientSocket->waitForBytesWritten(); - clientSocket->disconnectFromServer(); - QVERIFY(client.waitForReadyRead()); + clientSocket->close(); + server.close(); + + // Wait for the client to notice the broken connection. + int timeout = 5000; + do { + const int timestep = 100; + QTest::qWait(timestep); + timeout -= timestep; + } while (!readChannelFinishedSpy.count() && timeout > 0); + + QVERIFY(!readChannelFinishedSpy.isEmpty()); QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); - QVERIFY(client.waitForDisconnected()); QCOMPARE(client.state(), QLocalSocket::UnconnectedState); } |