From d0e579826c13baf38c99b711dcfc1fd8b6f2ee30 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 21 Jun 2008 09:15:29 +0000 Subject: [PATCH] added an option to not count inactive torrents against the limits for auto managed torrents --- include/libtorrent/session_settings.hpp | 6 ++++++ src/session_impl.cpp | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 677bd8b84..c54e8a386 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -126,6 +126,7 @@ namespace libtorrent , peer_tos(0) , active_downloads(8) , active_seeds(5) + , dont_count_inactive_torrents(true) , auto_manage_interval(30) , share_ratio_limit(2.f) , seed_time_ratio_limit(7.f) @@ -363,6 +364,11 @@ namespace libtorrent int active_downloads; int active_seeds; + // if this is true, torrents that don't have any significant + // transfers are not counted as active when determining which + // auto managed torrents to pause and resume + bool dont_count_inactive_torrents; + // the number of seconds in between recalculating which // torrents to activate and which ones to queue int auto_manage_interval; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 342c9bcd4..b3612ada7 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1357,10 +1357,16 @@ namespace aux { , end(downloaders.end()); i != end; ++i) { torrent* t = *i; + if (!t->is_paused() + && settings().dont_count_inactive_torrents + && t->statistics().upload_payload_rate() == 0.f + && t->statistics().download_payload_rate() == 0.f) + continue; + if (num_downloaders > 0) { if (t->state() != torrent_status::queued_for_checking - && t->state() != torrent_status::checking_files) + && t->state() != torrent_status::checking_files) { --num_downloaders; --num_seeds; @@ -1377,6 +1383,12 @@ namespace aux { , end(seeds.end()); i != end; ++i) { torrent* t = *i; + if (!t->is_paused() + && settings().dont_count_inactive_torrents + && t->statistics().upload_payload_rate() == 0.f + && t->statistics().download_payload_rate() == 0.f) + continue; + if (num_seeds > 0) { --num_downloaders;