QLocalSocket/Win: prevent writing to broken pipe
When a peer closes the connection, the device remains opened for reading purposes. However, we should disable writing on disconnected socket. Otherwise, if the user issues a write() call, a new pipe writer object will be created and the write call occurs with invalid handle value. Pick-to: 5.15 Change-Id: Id136798c7663df1fce7ed0aa4e3c6f5c65218a11 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>bb10
parent
a8b687b101
commit
53b4556332
|
|
@ -212,6 +212,12 @@ qint64 QLocalSocket::skipData(qint64 maxSize)
|
|||
qint64 QLocalSocket::writeData(const char *data, qint64 len)
|
||||
{
|
||||
Q_D(QLocalSocket);
|
||||
if (!isValid()) {
|
||||
d->error = OperationError;
|
||||
d->errorString = tr("Socket is not connected");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
d->write(data, len);
|
||||
|
|
|
|||
|
|
@ -1267,6 +1267,7 @@ void tst_QLocalSocket::syncDisconnectNotify()
|
|||
QVERIFY(serverSocket);
|
||||
delete serverSocket;
|
||||
QCOMPARE(client.waitForReadyRead(), false);
|
||||
QVERIFY(!client.putChar(0));
|
||||
}
|
||||
|
||||
void tst_QLocalSocket::asyncDisconnectNotify()
|
||||
|
|
|
|||
Loading…
Reference in New Issue