mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Use QSet for tracking server connections
We don't need to maintain order between connections so QSet would be more suitable.
This commit is contained in:
parent
4e5a85dda5
commit
df6df20969
2 changed files with 5 additions and 4 deletions
|
@ -97,19 +97,19 @@ void Server::incomingConnection(qintptr socketDescriptor)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Connection *c = new Connection(serverSocket, m_requestHandler, this);
|
Connection *c = new Connection(serverSocket, m_requestHandler, this);
|
||||||
m_connections.append(c);
|
m_connections.insert(c);
|
||||||
connect(serverSocket, &QAbstractSocket::disconnected, this, [c, this]() { removeConnection(c); });
|
connect(serverSocket, &QAbstractSocket::disconnected, this, [c, this]() { removeConnection(c); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::removeConnection(Connection *connection)
|
void Server::removeConnection(Connection *connection)
|
||||||
{
|
{
|
||||||
m_connections.removeOne(connection);
|
m_connections.remove(connection);
|
||||||
connection->deleteLater();
|
connection->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::dropTimedOutConnection()
|
void Server::dropTimedOutConnection()
|
||||||
{
|
{
|
||||||
QMutableListIterator<Connection *> i(m_connections);
|
QMutableSetIterator<Connection *> i(m_connections);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Connection *connection = i.next();
|
Connection *connection = i.next();
|
||||||
if (connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
if (connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#ifndef HTTP_SERVER_H
|
#ifndef HTTP_SERVER_H
|
||||||
#define HTTP_SERVER_H
|
#define HTTP_SERVER_H
|
||||||
|
|
||||||
|
#include <QSet>
|
||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
|
@ -66,7 +67,7 @@ namespace Http
|
||||||
void removeConnection(Connection *connection);
|
void removeConnection(Connection *connection);
|
||||||
|
|
||||||
IRequestHandler *m_requestHandler;
|
IRequestHandler *m_requestHandler;
|
||||||
QList<Connection *> m_connections; // for tracking persistent connections
|
QSet<Connection *> m_connections; // for tracking persistent connections
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
QList<QSslCipher> safeCipherList() const;
|
QList<QSslCipher> safeCipherList() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue