Browse Source

Add "Socket backlog size" option

The default value in libtorrent is 5 which is too small nowadays.
The new default value 30 is chosen to be in line with
QTcpServer::maxPendingConnections().
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
6286bc716c
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 19
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 11
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h

19
src/base/bittorrent/session.cpp

@ -282,6 +282,7 @@ Session::Session(QObject *parent) @@ -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() @@ -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<int, int> ports(port, port);
@ -2955,6 +2959,19 @@ void Session::setSendBufferWatermarkFactor(const int value) @@ -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;

3
src/base/bittorrent/session.h

@ -340,6 +340,8 @@ namespace BitTorrent @@ -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 @@ -595,6 +597,7 @@ namespace BitTorrent
CachedSettingValue<int> m_sendBufferWatermark;
CachedSettingValue<int> m_sendBufferLowWatermark;
CachedSettingValue<int> m_sendBufferWatermarkFactor;
CachedSettingValue<int> m_socketBacklogSize;
CachedSettingValue<bool> m_isAnonymousModeEnabled;
CachedSettingValue<bool> m_isQueueingEnabled;
CachedSettingValue<int> m_maxActiveDownloads;

11
src/gui/advancedsettings.cpp

@ -100,7 +100,8 @@ enum AdvSettingsRows @@ -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() @@ -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() @@ -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<int>::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<int>::max());

2
src/gui/advancedsettings.h

@ -61,7 +61,7 @@ private: @@ -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,

Loading…
Cancel
Save