From 5edfb3c7ee338c0b562f33a8c4315454bfc18886 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 22 May 2015 14:07:34 +0200 Subject: QWebSocketServer: handle new connection after invalid one Manually tested with sslechoserver and sslechoclient in examples, invalid connection from "telnet localhost 1234". Task-number: QTBUG-44866 Change-Id: I19c29c7c5f57eef4f9ae069e105fd1db346fb5c5 Reviewed-by: Luca Niccoli Reviewed-by: Alex Blasche --- src/websockets/qwebsocketserver_p.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp index 73ca9d7..bc23674 100644 --- a/src/websockets/qwebsocketserver_p.cpp +++ b/src/websockets/qwebsocketserver_p.cpp @@ -370,13 +370,15 @@ void QWebSocketServerPrivate::setError(QWebSocketProtocol::CloseCode code, const */ void QWebSocketServerPrivate::onNewConnection() { - QTcpSocket *pTcpSocket = m_pTcpServer->nextPendingConnection(); - //use a queued connection because a QSslSocket - //needs the event loop to process incoming data - //if not queued, data is incomplete when handshakeReceived is called - QObjectPrivate::connect(pTcpSocket, &QTcpSocket::readyRead, - this, &QWebSocketServerPrivate::handshakeReceived, - Qt::QueuedConnection); + while (m_pTcpServer->hasPendingConnections()) { + QTcpSocket *pTcpSocket = m_pTcpServer->nextPendingConnection(); + //use a queued connection because a QSslSocket + //needs the event loop to process incoming data + //if not queued, data is incomplete when handshakeReceived is called + QObjectPrivate::connect(pTcpSocket, &QTcpSocket::readyRead, + this, &QWebSocketServerPrivate::handshakeReceived, + Qt::QueuedConnection); + } } /*! -- cgit v1.2.1