diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index aa3e74cb9..4b1c89356 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -282,6 +282,7 @@ Session::Session(QObject *parent) , m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500) , m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10) , m_sendBufferWatermarkFactor(BITTORRENT_SESSION_KEY("SendBufferWatermarkFactor"), 50) + , m_socketBacklogSize(BITTORRENT_SESSION_KEY("SocketBacklogSize"), 30) , m_isAnonymousModeEnabled(BITTORRENT_SESSION_KEY("AnonymousModeEnabled"), false) , m_isQueueingEnabled(BITTORRENT_SESSION_KEY("QueueingSystemEnabled"), true) , m_maxActiveDownloads(BITTORRENT_SESSION_KEY("MaxActiveDownloads"), 3, lowerLimited(-1)) @@ -1127,10 +1128,13 @@ void Session::initMetrics() void Session::configure(lt::settings_pack &settingsPack) { + // from libtorrent doc: + // It will not take affect until the listen_interfaces settings is updated + settingsPack.set_int(lt::settings_pack::listen_queue_size, socketBacklogSize()); + #ifdef Q_OS_WIN QString chosenIP; #endif - if (m_listenInterfaceChanged) { const ushort port = this->port(); const std::pair ports(port, port); @@ -2955,6 +2959,19 @@ void Session::setSendBufferWatermarkFactor(const int value) configureDeferred(); } +int Session::socketBacklogSize() const +{ + return m_socketBacklogSize; +} + +void Session::setSocketBacklogSize(const int value) +{ + if (value == m_socketBacklogSize) return; + + m_socketBacklogSize = value; + configureDeferred(); +} + bool Session::isAnonymousModeEnabled() const { return m_isAnonymousModeEnabled; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 6dfdaacc9..10b2b79f3 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -340,6 +340,8 @@ namespace BitTorrent void setSendBufferLowWatermark(int value); int sendBufferWatermarkFactor() const; void setSendBufferWatermarkFactor(int value); + int socketBacklogSize() const; + void setSocketBacklogSize(int value); bool isAnonymousModeEnabled() const; void setAnonymousModeEnabled(bool enabled); bool isQueueingSystemEnabled() const; @@ -595,6 +597,7 @@ namespace BitTorrent CachedSettingValue m_sendBufferWatermark; CachedSettingValue m_sendBufferLowWatermark; CachedSettingValue m_sendBufferWatermarkFactor; + CachedSettingValue m_socketBacklogSize; CachedSettingValue m_isAnonymousModeEnabled; CachedSettingValue m_isQueueingEnabled; CachedSettingValue m_maxActiveDownloads; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 60b045474..d418e381e 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -100,7 +100,8 @@ enum AdvSettingsRows SEND_BUF_WATERMARK, SEND_BUF_LOW_WATERMARK, SEND_BUF_WATERMARK_FACTOR, - // ports + // networking & ports + SOCKET_BACKLOG_SIZE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, UTP_MIX_MODE, @@ -171,6 +172,8 @@ void AdvancedSettings::saveAdvancedSettings() session->setSendBufferWatermark(spinBoxSendBufferWatermark.value()); session->setSendBufferLowWatermark(spinBoxSendBufferLowWatermark.value()); session->setSendBufferWatermarkFactor(spinBoxSendBufferWatermarkFactor.value()); + // Socket listen backlog size + session->setSocketBacklogSize(spinBoxSocketBacklogSize.value()); // Save resume data interval session->setSaveResumeDataInterval(spinBoxSaveResumeDataInterval.value()); // Outgoing ports @@ -394,6 +397,12 @@ void AdvancedSettings::loadAdvancedSettings() spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor()); addRow(SEND_BUF_WATERMARK_FACTOR, (tr("Send buffer watermark factor") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor", "(?)")) , &spinBoxSendBufferWatermarkFactor); + // Socket listen backlog size + spinBoxSocketBacklogSize.setMinimum(1); + spinBoxSocketBacklogSize.setMaximum(std::numeric_limits::max()); + spinBoxSocketBacklogSize.setValue(session->socketBacklogSize()); + addRow(SOCKET_BACKLOG_SIZE, (tr("Socket backlog size") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#listen_queue_size", "(?)")) + , &spinBoxSocketBacklogSize); // Save resume data interval spinBoxSaveResumeDataInterval.setMinimum(0); spinBoxSaveResumeDataInterval.setMaximum(std::numeric_limits::max()); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 41d8dfbf0..576a6b922 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -61,7 +61,7 @@ private: QLabel labelQbtLink, labelLibtorrentLink; QSpinBox spinBoxAsyncIOThreads, spinBoxCheckingMemUsage, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxTrackerPort, spinBoxCacheTTL, spinBoxSendBufferWatermark, spinBoxSendBufferLowWatermark, - spinBoxSendBufferWatermarkFactor, spinBoxSavePathHistoryLength; + spinBoxSendBufferWatermarkFactor, spinBoxSocketBacklogSize, spinBoxSavePathHistoryLength; QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding, checkBoxProgramNotifications, checkBoxTorrentAddedNotifications, checkBoxTrackerFavicon, checkBoxTrackerStatus, checkBoxConfirmTorrentRecheck, checkBoxConfirmRemoveAllTags, checkBoxListenIPv6, checkBoxAnnounceAllTrackers, checkBoxAnnounceAllTiers,