Browse Source

Expose stop_tracker_timeout in advanced settings

adaptive-webui-19844
an0n666 5 years ago
parent
commit
3f223c3a45
  1. 18
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 9
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h
  5. 5
      src/webui/api/appcontroller.cpp
  6. 10
      src/webui/www/private/views/preferences.html

18
src/base/bittorrent/session.cpp

@ -373,6 +373,7 @@ Session::Session(QObject *parent) @@ -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() @@ -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) @@ -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) @@ -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;

3
src/base/bittorrent/session.h

@ -325,6 +325,8 @@ namespace BitTorrent @@ -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 @@ -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;

9
src/gui/advancedsettings.cpp

@ -89,6 +89,7 @@ enum AdvSettingsRows @@ -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() @@ -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() @@ -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());

2
src/gui/advancedsettings.h

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

5
src/webui/api/appcontroller.cpp

@ -270,6 +270,8 @@ void AppController::preferencesAction() @@ -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() @@ -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());

10
src/webui/www/private/views/preferences.html

@ -878,6 +878,14 @@ @@ -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>
@ -1735,6 +1743,7 @@ @@ -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 @@ @@ -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'));

Loading…
Cancel
Save