From e66dcd51d0e5517e88cd59912fd08501522a2902 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Thu, 19 May 2016 11:34:05 -0700 Subject: Fixed erroneous detection of server disconnect condition QAbstractSocket::atEnd does not check actual connection state it only checks if data is ready to be read. Under some conditions (e.g. slow network) data may not be available yet but it doesn't mean the server dropped connection. When more data comes FSM will pick it up and handle as expected. The right way to check disconnect is to check for actual socket state. Task-number: QTBUG-51069 Change-Id: I17d7110fbefdba2d5378a71935ab5923f8c1bf3e Reviewed-by: Thiago Macieira --- src/websockets/qwebsocket_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 2fd52fe..3df969e 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -975,7 +975,7 @@ void QWebSocketPrivate::processHandshake(QTcpSocket *pSocket) } if (m_handshakeState != ParsingHeaderState) { - if (pSocket->atEnd()) { + if (pSocket->state() != QAbstractSocket::ConnectedState) { errorDescription = QWebSocket::tr("QWebSocketPrivate::processHandshake: Connection closed while reading header."); break; } -- cgit v1.2.1