mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 22:18:05 -06: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:
@@ -107,19 +107,19 @@ void Server::incomingConnection(const qintptr socketDescriptor)
|
||||
}
|
||||
|
||||
auto *c = new Connection(serverSocket, m_requestHandler, this);
|
||||
m_connections.append(c);
|
||||
m_connections.insert(c);
|
||||
connect(serverSocket, &QAbstractSocket::disconnected, this, [c, this]() { removeConnection(c); });
|
||||
}
|
||||
|
||||
void Server::removeConnection(Connection *connection)
|
||||
{
|
||||
m_connections.removeOne(connection);
|
||||
m_connections.remove(connection);
|
||||
connection->deleteLater();
|
||||
}
|
||||
|
||||
void Server::dropTimedOutConnection()
|
||||
{
|
||||
QMutableListIterator<Connection *> i(m_connections);
|
||||
QMutableSetIterator<Connection *> i(m_connections);
|
||||
while (i.hasNext()) {
|
||||
Connection *connection = i.next();
|
||||
if (connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
||||
|
||||
Reference in New Issue
Block a user