diff --git a/src/choker.cpp b/src/choker.cpp index d3cf88071..103bd9802 100644 --- a/src/choker.cpp +++ b/src/choker.cpp @@ -133,14 +133,14 @@ namespace libtorrent // when seeding, prefer the peer we're uploading the fastest to c1 = lhs->uploaded_in_last_round(); c2 = rhs->uploaded_in_last_round(); - + // take torrent priority into account c1 *= prio1; c2 *= prio2; if (c1 > c2) return true; if (c2 > c1) return false; - + // prioritize the one that has waited the longest to be unchoked // the round-robin unchoker relies on this logic. Don't change it // without moving this into that unchoker logic @@ -200,7 +200,7 @@ namespace libtorrent ? t2_total - rhs->num_have_pieces() : rhs->num_have_pieces()) * 1000 / t2_total; if (score1 > score2) return true; if (score2 > score1) return false; - + // prioritize the one that has waited the longest to be unchoked // the round-robin unchoker relies on this logic. Don't change it // without moving this into that unchoker logic @@ -215,7 +215,7 @@ namespace libtorrent c1 = lhs->uploaded_in_last_round(); c2 = rhs->uploaded_in_last_round(); - + // take torrent priority into account c1 *= lhs->get_priority(peer_connection::upload_channel); c2 *= rhs->get_priority(peer_connection::upload_channel); @@ -256,7 +256,18 @@ namespace libtorrent , time_duration unchoke_interval , aux::session_settings const& sett) { +#if TORRENT_USE_ASSERTS + for (std::vector::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::max)(); // ==== BitTyrant ==== // diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 07c7270df..82a0477a9 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -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::max)();