mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
commit
4253515736
3 changed files with 17 additions and 8 deletions
|
@ -97,16 +97,23 @@ void Server::incomingConnection(qintptr socketDescriptor)
|
|||
#endif
|
||||
|
||||
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); });
|
||||
}
|
||||
|
||||
void Server::removeConnection(Connection *connection)
|
||||
{
|
||||
m_connections.remove(connection);
|
||||
connection->deleteLater();
|
||||
}
|
||||
|
||||
void Server::dropTimedOutConnection()
|
||||
{
|
||||
QMutableListIterator<Connection *> i(m_connections);
|
||||
QMutableSetIterator<Connection *> i(m_connections);
|
||||
while (i.hasNext()) {
|
||||
auto connection = i.next();
|
||||
if (connection->isClosed() || connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
||||
delete connection;
|
||||
Connection *connection = i.next();
|
||||
if (connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
||||
connection->deleteLater();
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#ifndef HTTP_SERVER_H
|
||||
#define HTTP_SERVER_H
|
||||
|
||||
#include <QSet>
|
||||
#include <QTcpServer>
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
|
@ -63,9 +64,10 @@ namespace Http
|
|||
|
||||
private:
|
||||
void incomingConnection(qintptr socketDescriptor);
|
||||
void removeConnection(Connection *connection);
|
||||
|
||||
IRequestHandler *m_requestHandler;
|
||||
QList<Connection *> m_connections; // for tracking persistent connections
|
||||
QSet<Connection *> m_connections; // for tracking persistent connections
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QList<QSslCipher> safeCipherList() const;
|
||||
|
|
|
@ -168,12 +168,12 @@ namespace Utils
|
|||
{
|
||||
if ((static_cast<std::size_t>(versionParts.size()) > N)
|
||||
|| (static_cast<std::size_t>(versionParts.size()) < Mandatory))
|
||||
throw std::runtime_error ("Incorrect number of version components");
|
||||
throw std::runtime_error("Incorrect number of version components");
|
||||
|
||||
bool ok = false;
|
||||
ComponentsArray res {{}};
|
||||
for (std::size_t i = 0; i < static_cast<std::size_t>(versionParts.size()); ++i) {
|
||||
res[i] = static_cast<T>(versionParts[i].toInt(&ok));
|
||||
res[i] = static_cast<T>(versionParts[static_cast<typename StringsList::size_type>(i)].toInt(&ok));
|
||||
if (!ok)
|
||||
throw std::runtime_error("Can not parse version component");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue