From cac6132aaead5d753928e459a61b114c6a4f9670 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 14 Oct 2008 07:41:05 +0000 Subject: [PATCH] don't resume a torrent if there aren't enough upload slots --- src/session_impl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 12dd5dc8c..e71dbe8d9 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1360,19 +1360,23 @@ namespace aux { > bind(&torrent::seed_rank, _2, boost::ref(m_settings))); } + int total_running = 0; for (std::vector::iterator i = downloaders.begin() , end(downloaders.end()); i != end; ++i) { torrent* t = *i; - if (!t->is_paused() && !is_active(t, settings()) && hard_limit > 0) + if (!t->is_paused() && !is_active(t, settings()) + && hard_limit > 0 && total_running < m_max_uploads) { --hard_limit; + ++total_running; continue; } if (num_downloaders > 0 && hard_limit > 0) { --hard_limit; + ++total_running; if (t->state() != torrent_status::queued_for_checking && t->state() != torrent_status::checking_files) { @@ -1390,9 +1394,11 @@ namespace aux { , end(seeds.end()); i != end; ++i) { torrent* t = *i; - if (!t->is_paused() && !is_active(t, settings()) && hard_limit > 0) + if (!t->is_paused() && !is_active(t, settings()) + && hard_limit > 0 && total_running < m_max_uploads) { --hard_limit; + ++total_running; continue; } @@ -1400,6 +1406,7 @@ namespace aux { { --hard_limit; --num_seeds; + ++total_running; if (t->is_paused()) t->resume(); } else