Merge pull request #514 from arvidn/allowed-unchoke-1.1

attempt to uphold the invariant that the num_unchoke_slots
This commit is contained in:
Arvid Norberg 2016-03-04 16:43:38 -05:00
commit 00f3406402
2 changed files with 17 additions and 7 deletions

View File

@ -256,7 +256,18 @@ namespace libtorrent
, time_duration unchoke_interval
, aux::session_settings const& sett)
{
#if TORRENT_USE_ASSERTS
for (std::vector<peer_connection*>::iterator i = peers.begin()
, end(peers.end()); i != end; ++i)
{
TORRENT_ASSERT((*i)->self());
TORRENT_ASSERT((*i)->associated_torrent().lock());
}
#endif
int upload_slots = sett.get_int(settings_pack::unchoke_slots_limit);
if (upload_slots < 0)
upload_slots = (std::numeric_limits<int>::max)();
// ==== BitTyrant ====
//

View File

@ -4195,6 +4195,7 @@ retry:
int const allowed_upload_slots = unchoke_sort(peers, max_upload_rate
, unchoke_interval, m_settings);
m_stats_counters.set_value(counters::num_unchoke_slots
, allowed_upload_slots);
@ -6140,9 +6141,7 @@ retry:
void session_impl::update_unchoke_limit()
{
int unchoke_limit = m_settings.get_int(settings_pack::unchoke_slots_limit);
int allowed_upload_slots = unchoke_limit;
int allowed_upload_slots = m_settings.get_int(settings_pack::unchoke_slots_limit);
if (allowed_upload_slots < 0)
allowed_upload_slots = (std::numeric_limits<int>::max)();