forked from premiere/premiere-libtorrent
fix issue with unchoke_slots_limit not preserving its value correctly
This commit is contained in:
parent
ef724014aa
commit
7f3aac3959
|
@ -1561,9 +1561,12 @@ namespace libtorrent
|
|||
// up read jobs increases too far.
|
||||
int read_job_every = m_settings.read_job_every;
|
||||
|
||||
if (m_sorted_read_jobs.size() > m_settings.unchoke_slots_limit * 2)
|
||||
int unchoke_limit = m_settings.unchoke_slots_limit;
|
||||
if (unchoke_limit < 0) unchoke_limit = 100;
|
||||
|
||||
if (m_sorted_read_jobs.size() > unchoke_limit * 2)
|
||||
{
|
||||
int range = m_settings.unchoke_slots_limit;
|
||||
int range = unchoke_limit;
|
||||
int exceed = m_sorted_read_jobs.size() - range * 2;
|
||||
read_job_every = (exceed * 1 + (range - exceed) * read_job_every) / 2;
|
||||
if (read_job_every < 1) read_job_every = 1;
|
||||
|
|
|
@ -1534,7 +1534,8 @@ namespace libtorrent
|
|||
// just unchoke it immediately
|
||||
send_unchoke();
|
||||
}
|
||||
else if (m_ses.num_uploads() < m_ses.settings().unchoke_slots_limit
|
||||
else if ((m_ses.num_uploads() < m_ses.settings().unchoke_slots_limit
|
||||
|| m_ses.settings().unchoke_slots_limit < 0)
|
||||
&& (t->ratio() == 0
|
||||
|| share_diff() >= size_type(-free_upload_amount)
|
||||
|| t->is_finished()))
|
||||
|
@ -1555,7 +1556,8 @@ namespace libtorrent
|
|||
else
|
||||
{
|
||||
std::string reason;
|
||||
if (m_ses.num_uploads() >= m_ses.settings().unchoke_slots_limit)
|
||||
if (m_ses.num_uploads() >= m_ses.settings().unchoke_slots_limit
|
||||
&& m_ses.settings().unchoke_slots_limit >= 0)
|
||||
{
|
||||
peer_log("DID NOT UNCHOKE [ the number of uploads (%d)"
|
||||
"is more than or equal to the limit (%d) ]"
|
||||
|
|
|
@ -4131,7 +4131,8 @@ namespace aux {
|
|||
++m_allowed_upload_slots;
|
||||
}
|
||||
else if (m_upload_rate.queue_size() > 1
|
||||
&& m_allowed_upload_slots > m_settings.unchoke_slots_limit)
|
||||
&& m_allowed_upload_slots > m_settings.unchoke_slots_limit
|
||||
&& m_settings.unchoke_slots_limit >= 0)
|
||||
{
|
||||
--m_allowed_upload_slots;
|
||||
}
|
||||
|
@ -5163,10 +5164,10 @@ namespace aux {
|
|||
|
||||
void session_impl::update_unchoke_limit()
|
||||
{
|
||||
if (m_settings.unchoke_slots_limit < 0)
|
||||
m_settings.unchoke_slots_limit = (std::numeric_limits<int>::max)();
|
||||
|
||||
m_allowed_upload_slots = m_settings.unchoke_slots_limit;
|
||||
if (m_allowed_upload_slots < 0)
|
||||
m_allowed_upload_slots = (std::numeric_limits<int>::max)();
|
||||
|
||||
if (m_settings.num_optimistic_unchoke_slots >= m_allowed_upload_slots / 2)
|
||||
{
|
||||
if (m_alerts.should_post<performance_alert>())
|
||||
|
@ -5621,7 +5622,6 @@ namespace aux {
|
|||
|
||||
std::set<peer_connection*> unique_peers;
|
||||
TORRENT_ASSERT(m_settings.connections_limit > 0);
|
||||
TORRENT_ASSERT(m_settings.unchoke_slots_limit >= 0);
|
||||
if (m_settings.choking_algorithm == session_settings::auto_expand_choker)
|
||||
TORRENT_ASSERT(m_allowed_upload_slots >= m_settings.unchoke_slots_limit);
|
||||
int unchokes = 0;
|
||||
|
|
|
@ -270,6 +270,16 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
|||
sett.unchoke_slots_limit = 0;
|
||||
}
|
||||
|
||||
sett.unchoke_slots_limit = 0;
|
||||
ses1.set_settings(sett);
|
||||
TEST_CHECK(ses1.settings().unchoke_slots_limit == 0);
|
||||
sett.unchoke_slots_limit = -1;
|
||||
ses1.set_settings(sett);
|
||||
TEST_CHECK(ses1.settings().unchoke_slots_limit == -1);
|
||||
sett.unchoke_slots_limit = 8;
|
||||
ses1.set_settings(sett);
|
||||
TEST_CHECK(ses1.settings().unchoke_slots_limit == 8);
|
||||
|
||||
// we need a short reconnect time since we
|
||||
// finish the torrent and then restart it
|
||||
// immediately to complete the second half.
|
||||
|
|
Loading…
Reference in New Issue