From dfaffcbf2a20cd7ff781de88ac3e73d9f17d1cdf Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 30 Oct 2015 15:09:55 +0100 Subject: QWindowsPipeReader: fix occasional "Unknown error 995" After canceling the asynchronous read operation, the notified() slot receives ERROR_OPERATION_ABORTED. We must not handle this situation as an error. This amends commit 5ce567c5. Task-number: QTBUG-48336 Change-Id: Iff948ceb3ad1f805a9de8c188fbc39ed4c76ba82 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qwindowspipereader.cpp | 4 +++ .../socket/qlocalsocket/tst_qlocalsocket.cpp | 29 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index c1f5d2aace..3200a70c94 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -186,6 +186,10 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode, case ERROR_PIPE_NOT_CONNECTED: pipeBroken = true; break; + case ERROR_OPERATION_ABORTED: + if (stopped) + break; + // fall through default: emit winError(errorCode, QLatin1String("QWindowsPipeReader::notified")); pipeBroken = true; diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 4881d86937..9130aff4e2 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -98,6 +98,7 @@ private slots: void removeServer(); void recycleServer(); + void recycleClientSocket(); void multiConnect(); void writeOnlySocket(); @@ -954,6 +955,34 @@ void tst_QLocalSocket::recycleServer() QVERIFY(server.nextPendingConnection() != 0); } +void tst_QLocalSocket::recycleClientSocket() +{ + const QByteArrayList lines = QByteArrayList() << "Have you heard of that new band" + << "\"1023 Megabytes\"?" + << "They haven't made it to a gig yet."; + QLocalServer server; + const QString serverName = QStringLiteral("recycleClientSocket"); + QVERIFY(server.listen(serverName)); + QLocalSocket client; + QSignalSpy clientReadyReadSpy(&client, SIGNAL(readyRead())); + QSignalSpy clientErrorSpy(&client, SIGNAL(error(QLocalSocket::LocalSocketError))); + for (int i = 0; i < lines.count(); ++i) { + client.abort(); + clientReadyReadSpy.clear(); + client.connectToServer(serverName); + QVERIFY(client.waitForConnected()); + QVERIFY(server.waitForNewConnection()); + QLocalSocket *serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + connect(serverSocket, &QLocalSocket::disconnected, &QLocalSocket::deleteLater); + serverSocket->write(lines.at(i)); + serverSocket->flush(); + QVERIFY(clientReadyReadSpy.wait()); + QCOMPARE(client.readAll(), lines.at(i)); + QVERIFY(clientErrorSpy.isEmpty()); + } +} + void tst_QLocalSocket::multiConnect() { QLocalServer server; -- cgit v1.2.3