diff --git a/include/libtorrent/aux_/allocate_resources_impl.hpp b/include/libtorrent/aux_/allocate_resources_impl.hpp index 2f4e6cb8e..fb355081a 100644 --- a/include/libtorrent/aux_/allocate_resources_impl.hpp +++ b/include/libtorrent/aux_/allocate_resources_impl.hpp @@ -192,6 +192,7 @@ namespace libtorrent // a consumer that uses 95% or more of its assigned // quota is considered saturating size_type used = r.used; + if (r.given == 0) continue; if (used * 20 / r.given >= 19) { ++num_saturated; @@ -233,7 +234,7 @@ namespace libtorrent int target; size_type used = r.used; - if (used * 20 / r.given >= 19) + if (r.given > 0 && used * 20 / r.given >= 19) { assert(num_saturated > 0); target = div_round_up(saturated_sum, num_saturated); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 7fa804e4c..a1c5e0dce 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -992,19 +992,6 @@ namespace libtorrent { namespace detail , m_torrents , &torrent::m_dl_bandwidth_quota); -#ifndef NDEBUG - size_type sum_ul = 0; - size_type sum_dl = 0; - for (torrent_map::iterator i = m_torrents.begin(); - i != m_torrents.end(); ++i) - { - sum_ul += i->second->m_ul_bandwidth_quota.given; - sum_dl += i->second->m_dl_bandwidth_quota.given; - } - assert(m_upload_rate == -1 || sum_ul == int(m_upload_rate * tick_interval)); - assert(m_download_rate == -1 || sum_dl == int(m_download_rate * tick_interval)); -#endif - allocate_resources(m_max_uploads == -1 ? std::numeric_limits::max() : m_max_uploads @@ -1521,6 +1508,7 @@ namespace libtorrent { namespace detail void session_impl::start_dht(entry const& startup_state) { mutex_t::scoped_lock l(m_mutex); + m_dht.reset(); m_dht.reset(new dht::dht_tracker(m_selector , m_dht_settings, m_listen_interface.address() , startup_state));