summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMÃ¥rten Nordheim <marten.nordheim@qt.io>2017-10-27 10:29:52 (GMT)
committerLiang Qi <liang.qi@qt.io>2017-10-27 11:45:38 (GMT)
commitf88def9086fa3a546847034dd017c0e5bdd92ab8 (patch)
treec8856a4a2e83c7b7a93b2f7212f46d3a48b40ec1
parente962127cb9afbd3cf59d80931b76b1e6800f146f (diff)
downloadqtwebsockets-f88def9086fa3a546847034dd017c0e5bdd92ab8.tar.gz
Fix handshakeReceived not being invoked in some situation
In the rare case where the handshake was received before the signal and slot was connected it would never invoke handshakeReceived and the server would keep waiting. Task-number: QTBUG-64026 Change-Id: I86d54031d2583b6a0cf2b5348889b5ef859b9aab Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/websockets/qwebsocketserver_p.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp
index b7972b0..55e9484 100644
--- a/src/websockets/qwebsocketserver_p.cpp
+++ b/src/websockets/qwebsocketserver_p.cpp
@@ -490,6 +490,11 @@ void QWebSocketServerPrivate::handleConnection(QTcpSocket *pTcpSocket) const
QObjectPrivate::connect(pTcpSocket, &QTcpSocket::readyRead,
this, &QWebSocketServerPrivate::handshakeReceived,
Qt::QueuedConnection);
+ if (pTcpSocket->canReadLine()) {
+ // We received some data! We must emit now to be sure that handshakeReceived is called
+ // since the data could have been received before the signal and slot was connected.
+ emit pTcpSocket->readyRead();
+ }
QObjectPrivate::connect(pTcpSocket, &QTcpSocket::disconnected,
this, &QWebSocketServerPrivate::onSocketDisconnected);
}