summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/socket/qlocalsocket_win.cpp11
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp17
2 files changed, 28 insertions, 0 deletions
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 01cbd4b..5486f47 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -570,11 +570,22 @@ bool QLocalSocket::waitForReadyRead(int msecs)
if (d->state != QLocalSocket::ConnectedState)
return false;
+ // We already know that the pipe is gone, but did not enter the event loop yet.
+ if (d->pipeClosed) {
+ close();
+ return false;
+ }
+
Q_ASSERT(d->readSequenceStarted);
DWORD result = WaitForSingleObject(d->overlapped.hEvent, msecs == -1 ? INFINITE : msecs);
switch (result) {
case WAIT_OBJECT_0:
d->_q_notified();
+ // We just noticed that the pipe is gone.
+ if (d->pipeClosed) {
+ close();
+ return false;
+ }
return true;
case WAIT_TIMEOUT:
return false;
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index 1acd669..4cbb156 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -115,6 +115,7 @@ private slots:
void writeToClientAndDisconnect();
void debug();
void bytesWrittenSignal();
+ void syncDisconnectNotify();
void asyncDisconnectNotify();
#ifdef Q_OS_SYMBIAN
@@ -1061,6 +1062,22 @@ void tst_QLocalSocket::bytesWrittenSignal()
QVERIFY(writeThread.wait(2000));
}
+void tst_QLocalSocket::syncDisconnectNotify()
+{
+#ifdef Q_OS_SYMBIAN
+ unlink("syncDisconnectNotify");
+#endif
+
+ QLocalServer server;
+ QVERIFY(server.listen("syncDisconnectNotify"));
+ QLocalSocket client;
+ client.connectToServer("syncDisconnectNotify");
+ QVERIFY(server.waitForNewConnection());
+ QLocalSocket* serverSocket = server.nextPendingConnection();
+ QVERIFY(serverSocket);
+ delete serverSocket;
+ QCOMPARE(client.waitForReadyRead(), false);
+}
void tst_QLocalSocket::asyncDisconnectNotify()
{