Skip to content

Commit

Permalink
Merge pull request #11834 from an0n666/an0n666-expose-stop-tracker-ti…
Browse files Browse the repository at this point in the history
…meout

Expose stop tracker timeout in Advanced Settings (GUI + WebUI)
  • Loading branch information
Chocobo1 committed Jan 8, 2020
2 parents e2ac97a + 3f223c3 commit 0578605
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/base/bittorrent/session.cpp
Expand Up @@ -373,6 +373,7 @@ Session::Session(QObject *parent)
, m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false)
, m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true)
, m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 4)
, m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 1)
, m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 40)
, m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32)
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), -1)
Expand Down Expand Up @@ -1078,7 +1079,6 @@ void Session::initializeNativeSession()
pack.set_str(lt::settings_pack::user_agent, USER_AGENT);
pack.set_bool(lt::settings_pack::use_dht_as_fallback, false);
// Speed up exit
pack.set_int(lt::settings_pack::stop_tracker_timeout, 1);
pack.set_int(lt::settings_pack::auto_scrape_interval, 1200); // 20 minutes
pack.set_int(lt::settings_pack::auto_scrape_min_interval, 900); // 15 minutes
pack.set_int(lt::settings_pack::connection_speed, 20); // default is 10
Expand Down Expand Up @@ -1304,7 +1304,7 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_bool(lt::settings_pack::announce_to_all_tiers, announceToAllTiers());

settingsPack.set_int(lt::settings_pack::aio_threads, asyncIOThreads());

settingsPack.set_int(lt::settings_pack::stop_tracker_timeout, stopTrackerTimeout());
settingsPack.set_int(lt::settings_pack::file_pool_size, filePoolSize());

const int checkingMemUsageSize = checkingMemUsage() * 64;
Expand Down Expand Up @@ -3149,6 +3149,20 @@ void Session::setAsyncIOThreads(const int num)
configureDeferred();
}

int Session::stopTrackerTimeout() const
{
return m_stopTrackerTimeout;
}

void Session::setStopTrackerTimeout(const int value)
{
if (value == m_stopTrackerTimeout)
return;

m_stopTrackerTimeout = value;
configureDeferred();
}

int Session::filePoolSize() const
{
return m_filePoolSize;
Expand Down
3 changes: 3 additions & 0 deletions src/base/bittorrent/session.h
Expand Up @@ -325,6 +325,8 @@ namespace BitTorrent
void setAnnounceToAllTiers(bool val);
int asyncIOThreads() const;
void setAsyncIOThreads(int num);
int stopTrackerTimeout() const;
void setStopTrackerTimeout(int value);
int filePoolSize() const;
void setFilePoolSize(int size);
int checkingMemUsage() const;
Expand Down Expand Up @@ -604,6 +606,7 @@ namespace BitTorrent
CachedSettingValue<bool> m_announceToAllTrackers;
CachedSettingValue<bool> m_announceToAllTiers;
CachedSettingValue<int> m_asyncIOThreads;
CachedSettingValue<int> m_stopTrackerTimeout;
CachedSettingValue<int> m_filePoolSize;
CachedSettingValue<int> m_checkingMemUsage;
CachedSettingValue<int> m_diskCacheSize;
Expand Down
9 changes: 8 additions & 1 deletion src/gui/advancedsettings.cpp
Expand Up @@ -89,6 +89,7 @@ enum AdvSettingsRows
// libtorrent section
LIBTORRENT_HEADER,
ASYNC_IO_THREADS,
STOP_TRACKER_TIMEOUT,
FILE_POOL_SIZE,
CHECKING_MEM_USAGE,
// cache
Expand Down Expand Up @@ -177,6 +178,8 @@ void AdvancedSettings::saveAdvancedSettings()
#endif
// Async IO threads
session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value());
// Stop tracker timeout
session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value());
// File pool size
session->setFilePoolSize(m_spinBoxFilePoolSize.value());
// Checking Memory Usage
Expand Down Expand Up @@ -376,7 +379,11 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxAsyncIOThreads.setValue(session->asyncIOThreads());
addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#aio_threads", "(?)"))
, &m_spinBoxAsyncIOThreads);

// stop tracker timeout
m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout());
m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds"));
addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", "(?)"))
, &m_spinBoxStopTrackerTimeout);
// File pool size
m_spinBoxFilePoolSize.setMinimum(1);
m_spinBoxFilePoolSize.setMaximum(std::numeric_limits<int>::max());
Expand Down
2 changes: 1 addition & 1 deletion src/gui/advancedsettings.h
Expand Up @@ -57,7 +57,7 @@ private slots:
void loadAdvancedSettings();
template <typename T> void addRow(int row, const QString &text, T *widget);

QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxCache,
QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxStopTrackerTimeout, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxCache,
m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxListRefresh,
m_spinBoxTrackerPort, m_spinBoxCacheTTL, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark,
m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxSavePathHistoryLength;
Expand Down
5 changes: 5 additions & 0 deletions src/webui/api/appcontroller.cpp
Expand Up @@ -270,6 +270,8 @@ void AppController::preferencesAction()
// libtorrent preferences
// Async IO threads
data["async_io_threads"] = session->asyncIOThreads();
// stop tracker timeout
data["stop_tracker_timeout"] = session->stopTrackerTimeout();
// File pool size
data["file_pool_size"] = session->filePoolSize();
// Checking memory usage
Expand Down Expand Up @@ -669,6 +671,9 @@ void AppController::setPreferencesAction()
// Async IO threads
if (hasKey("async_io_threads"))
session->setAsyncIOThreads(it.value().toInt());
// Stop tracker timeout
if (hasKey("stop_tracker_timeout"))
session->setStopTrackerTimeout(it.value().toInt());
// File pool size
if (hasKey("file_pool_size"))
session->setFilePoolSize(it.value().toInt());
Expand Down
10 changes: 10 additions & 0 deletions src/webui/www/private/views/preferences.html
Expand Up @@ -878,6 +878,14 @@
<input type="text" id="asyncIOThreads" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="stopTrackerTimeout">QBT_TR(Stop tracker timeout:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="stopTrackerTimeout" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="filePoolSize">QBT_TR(File pool size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#file_pool_size" target="_blank">(?)</a></label>
Expand Down Expand Up @@ -1734,6 +1742,7 @@
$('resolvePeerCountries').setProperty('checked', pref.resolve_peer_countries);
// libtorrent section
$('asyncIOThreads').setProperty('value', pref.async_io_threads);
$('stopTrackerTimeout').setProperty('value', pref.stop_tracker_timeout);
$('filePoolSize').setProperty('value', pref.file_pool_size);
$('outstandMemoryWhenCheckingTorrents').setProperty('value', pref.checking_memory_use);
$('diskCache').setProperty('value', pref.disk_cache);
Expand Down Expand Up @@ -2098,6 +2107,7 @@

// libtorrent section
settings.set('async_io_threads', $('asyncIOThreads').getProperty('value'));
settings.set('stop_tracker_timeout', $('stopTrackerTimeout').getProperty('value'));
settings.set('file_pool_size', $('filePoolSize').getProperty('value'));
settings.set('checking_memory_use', $('outstandMemoryWhenCheckingTorrents').getProperty('value'));
settings.set('disk_cache', $('diskCache').getProperty('value'));
Expand Down

0 comments on commit 0578605

Please sign in to comment.