diff options
Diffstat (limited to 'src/network/socket')
-rw-r--r-- | src/network/socket/qtcpserver.cpp | 16 | ||||
-rw-r--r-- | src/network/socket/qtcpserver_p.h | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 95d1877a5d..e6ff34cee9 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -172,7 +172,7 @@ void QTcpServerPrivate::readNotification() { Q_Q(QTcpServer); for (;;) { - if (pendingConnections.count() >= maxConnections) { + if (totalPendingConnections() >= maxConnections) { #if defined (QTCPSERVER_DEBUG) qDebug("QTcpServerPrivate::_q_processIncomingConnection() too many connections"); #endif @@ -206,6 +206,20 @@ void QTcpServerPrivate::readNotification() } /*! + \internal + Return the amount of sockets currently in queue for the server. + This is to make maxPendingConnections work properly with servers that don't + necessarily have 'ready-to-go' sockets as soon as they connect, + e.g. QSslServer. + By default we just return pendingConnections.size(), which is equivalent to + what it did before. +*/ +int QTcpServerPrivate::totalPendingConnections() const +{ + return int(pendingConnections.size()); +} + +/*! Constructs a QTcpServer object. \a parent is passed to the QObject constructor. diff --git a/src/network/socket/qtcpserver_p.h b/src/network/socket/qtcpserver_p.h index a526549538..853a4aaf96 100644 --- a/src/network/socket/qtcpserver_p.h +++ b/src/network/socket/qtcpserver_p.h @@ -56,6 +56,7 @@ public: #endif virtual void configureCreatedSocket(); + virtual int totalPendingConnections() const; // from QAbstractSocketEngineReceiver void readNotification() override; |