From 3f223c3a45176299e525d3385e8f37968fc50a99 Mon Sep 17 00:00:00 2001 From: an0n666 <47396879+an0n666@users.noreply.github.com> Date: Mon, 6 Jan 2020 13:11:23 +0600 Subject: [PATCH] Expose stop_tracker_timeout in advanced settings --- src/base/bittorrent/session.cpp | 18 ++++++++++++++++-- src/base/bittorrent/session.h | 3 +++ src/gui/advancedsettings.cpp | 9 ++++++++- src/gui/advancedsettings.h | 2 +- src/webui/api/appcontroller.cpp | 5 +++++ src/webui/www/private/views/preferences.html | 10 ++++++++++ 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index c047f232a..b6b356e66 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -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) @@ -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 @@ -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; @@ -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; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 4591f4477..ae0fabd73 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -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; @@ -604,6 +606,7 @@ namespace BitTorrent CachedSettingValue m_announceToAllTrackers; CachedSettingValue m_announceToAllTiers; CachedSettingValue m_asyncIOThreads; + CachedSettingValue m_stopTrackerTimeout; CachedSettingValue m_filePoolSize; CachedSettingValue m_checkingMemUsage; CachedSettingValue m_diskCacheSize; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 80899a154..845af7c1a 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -89,6 +89,7 @@ enum AdvSettingsRows // libtorrent section LIBTORRENT_HEADER, ASYNC_IO_THREADS, + STOP_TRACKER_TIMEOUT, FILE_POOL_SIZE, CHECKING_MEM_USAGE, // cache @@ -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 @@ -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::max()); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 1122b58b9..9f5938f67 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -57,7 +57,7 @@ private: void loadAdvancedSettings(); template 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; diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index a8352a17b..bb518b6be 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -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 @@ -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()); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 3e8270b89..6ec809eda 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -878,6 +878,14 @@ + + + + + + + + @@ -1735,6 +1743,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); @@ -2099,6 +2108,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'));