QSSLSocket::readData return -1 when socket is not connected
As QAbstractSocket::readData does and as the documentation of QIODevice says "this function returns -1 in those cases (that is, reading on a closed socket..." Change-Id: I1e64673f6a6d792a640bd6cb28b2bb5a0f18dc36 Reviewed-by: Aleix Pol Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
678ff94ff2
commit
f78a189da5
|
|
@ -1993,6 +1993,8 @@ qint64 QSslSocket::readData(char *data, qint64 maxlen)
|
|||
// possibly trigger another transmit() to decrypt more data from the socket
|
||||
if (d->plainSocket->bytesAvailable())
|
||||
QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection);
|
||||
else if (d->state != QAbstractSocket::ConnectedState)
|
||||
return maxlen ? qint64(-1) : qint64(0);
|
||||
}
|
||||
|
||||
return readBytes;
|
||||
|
|
|
|||
|
|
@ -2162,6 +2162,13 @@ void tst_QSslSocket::waitForMinusOne()
|
|||
|
||||
// fifth verification: it should wait for 200 ms more
|
||||
QVERIFY(socket.waitForDisconnected(-1));
|
||||
|
||||
// sixth verification: reading from a disconnected socket returns -1
|
||||
// once we deplete the read buffer
|
||||
QCOMPARE(socket.state(), QAbstractSocket::UnconnectedState);
|
||||
socket.readAll();
|
||||
char aux;
|
||||
QCOMPARE(socket.read(&aux, 1), -1);
|
||||
}
|
||||
|
||||
class VerifyServer : public QTcpServer
|
||||
|
|
|
|||
Loading…
Reference in New Issue