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 <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
5a7f69f824
commit
dfaffcbf2a
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user