fixed division by zero problem in allocate_resources, removed incorrect asserts
This commit is contained in:
parent
8e289bb233
commit
1015864eeb
|
@ -192,6 +192,7 @@ namespace libtorrent
|
||||||
// a consumer that uses 95% or more of its assigned
|
// a consumer that uses 95% or more of its assigned
|
||||||
// quota is considered saturating
|
// quota is considered saturating
|
||||||
size_type used = r.used;
|
size_type used = r.used;
|
||||||
|
if (r.given == 0) continue;
|
||||||
if (used * 20 / r.given >= 19)
|
if (used * 20 / r.given >= 19)
|
||||||
{
|
{
|
||||||
++num_saturated;
|
++num_saturated;
|
||||||
|
@ -233,7 +234,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int target;
|
int target;
|
||||||
size_type used = r.used;
|
size_type used = r.used;
|
||||||
if (used * 20 / r.given >= 19)
|
if (r.given > 0 && used * 20 / r.given >= 19)
|
||||||
{
|
{
|
||||||
assert(num_saturated > 0);
|
assert(num_saturated > 0);
|
||||||
target = div_round_up(saturated_sum, num_saturated);
|
target = div_round_up(saturated_sum, num_saturated);
|
||||||
|
|
|
@ -992,19 +992,6 @@ namespace libtorrent { namespace detail
|
||||||
, m_torrents
|
, m_torrents
|
||||||
, &torrent::m_dl_bandwidth_quota);
|
, &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
|
allocate_resources(m_max_uploads == -1
|
||||||
? std::numeric_limits<int>::max()
|
? std::numeric_limits<int>::max()
|
||||||
: m_max_uploads
|
: m_max_uploads
|
||||||
|
@ -1521,6 +1508,7 @@ namespace libtorrent { namespace detail
|
||||||
void session_impl::start_dht(entry const& startup_state)
|
void session_impl::start_dht(entry const& startup_state)
|
||||||
{
|
{
|
||||||
mutex_t::scoped_lock l(m_mutex);
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
|
m_dht.reset();
|
||||||
m_dht.reset(new dht::dht_tracker(m_selector
|
m_dht.reset(new dht::dht_tracker(m_selector
|
||||||
, m_dht_settings, m_listen_interface.address()
|
, m_dht_settings, m_listen_interface.address()
|
||||||
, startup_state));
|
, startup_state));
|
||||||
|
|
Loading…
Reference in New Issue