summaryrefslogtreecommitdiff
path: root/src/websockets/qwebsocketserver_p.cpp
diff options
context:
space:
mode:
authorKurt Pattyn <pattyn.kurt@gmail.com>2014-01-04 15:43:53 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-04 15:45:14 +0100
commit7f8161d505f3cd5163481a6cf57103469fcaab06 (patch)
treebc621798c8f03caacb0fa36de7f7333ea0a82776 /src/websockets/qwebsocketserver_p.cpp
parent7898899529c4882cac519df07baad8f85906e797 (diff)
downloadqtwebsockets-7f8161d505f3cd5163481a6cf57103469fcaab06.tar.gz
Check on max pending connections before accepting a connection
Change-Id: Ia94540e131ce424e6306886861598f7f24f7577f Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Diffstat (limited to 'src/websockets/qwebsocketserver_p.cpp')
-rw-r--r--src/websockets/qwebsocketserver_p.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp
index e5e0f1e..4d5680f 100644
--- a/src/websockets/qwebsocketserver_p.cpp
+++ b/src/websockets/qwebsocketserver_p.cpp
@@ -385,6 +385,13 @@ void QWebSocketServerPrivate::handshakeReceived()
disconnect(pTcpSocket, SIGNAL(readyRead()), this, SLOT(handshakeReceived()));
+ if (m_pendingConnections.length() >= maxPendingConnections()) {
+ pTcpSocket->close();
+ qWarning() << tr("Too many pending connections: new websocket connection not accepted.");
+ setError(QWebSocketProtocol::CC_ABNORMAL_DISCONNECTION, tr("Too many pending connections."));
+ return;
+ }
+
QWebSocketHandshakeRequest request(pTcpSocket->peerPort(), isSecure);
QTextStream textStream(pTcpSocket);
textStream >> request;