don't resume a torrent if there aren't enough upload slots

This commit is contained in:
Arvid Norberg 2008-10-14 07:41:05 +00:00
parent 9a5e261c64
commit cac6132aae
1 changed files with 9 additions and 2 deletions

View File

@ -1360,19 +1360,23 @@ namespace aux {
> bind(&torrent::seed_rank, _2, boost::ref(m_settings))); > bind(&torrent::seed_rank, _2, boost::ref(m_settings)));
} }
int total_running = 0;
for (std::vector<torrent*>::iterator i = downloaders.begin() for (std::vector<torrent*>::iterator i = downloaders.begin()
, end(downloaders.end()); i != end; ++i) , end(downloaders.end()); i != end; ++i)
{ {
torrent* t = *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; --hard_limit;
++total_running;
continue; continue;
} }
if (num_downloaders > 0 && hard_limit > 0) if (num_downloaders > 0 && hard_limit > 0)
{ {
--hard_limit; --hard_limit;
++total_running;
if (t->state() != torrent_status::queued_for_checking if (t->state() != torrent_status::queued_for_checking
&& t->state() != torrent_status::checking_files) && t->state() != torrent_status::checking_files)
{ {
@ -1390,9 +1394,11 @@ namespace aux {
, end(seeds.end()); i != end; ++i) , end(seeds.end()); i != end; ++i)
{ {
torrent* t = *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; --hard_limit;
++total_running;
continue; continue;
} }
@ -1400,6 +1406,7 @@ namespace aux {
{ {
--hard_limit; --hard_limit;
--num_seeds; --num_seeds;
++total_running;
if (t->is_paused()) t->resume(); if (t->is_paused()) t->resume();
} }
else else