bandwidth manager fix

This commit is contained in:
Marcos Pinto 2007-12-09 18:50:22 +00:00
parent 91531deb6d
commit d355a42af8
4 changed files with 13 additions and 4 deletions

View File

@ -225,8 +225,14 @@ struct bandwidth_manager
}
#endif
TORRENT_ASSERT(peer->max_assignable_bandwidth(m_channel) > 0);
boost::shared_ptr<Torrent> t = peer->associated_torrent().lock();
if (peer->max_assignable_bandwidth(m_channel) == 0)
{
t->expire_bandwidth(m_channel, blk);
peer->assign_bandwidth(m_channel, 0);
return;
}
m_queue.push_back(bw_queue_entry<PeerConnection>(peer, blk, non_prioritized));
if (!non_prioritized)
{
@ -389,6 +395,7 @@ private:
if (max_assignable == 0)
{
t->expire_bandwidth(m_channel, qe.max_block_size);
qe.peer->assign_bandwidth(m_channel, 0);
TORRENT_ASSERT(amount == limit - m_current_quota);
continue;
}
@ -430,7 +437,7 @@ private:
if (block_size > qe.max_block_size) block_size = qe.max_block_size;
#ifdef TORRENT_VERBOSE_BANDWIDTH_LIMIT
std::cerr << " block_size = " << block_size << " amount = " << amount << std::endl;
std::cerr << " block_size = " << block_size << " amount = " << amount << std::endl;
#endif
if (amount < block_size / 2)
{

View File

@ -217,7 +217,7 @@ bool rpc_manager::incoming(msg const& m)
{
#ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(rpc) << "Reply with incorrect address and valid transaction id: "
<< tid << " from " << m.addr;
<< tid << " from " << m.addr << " expected: " << o->target_addr;
#endif
return false;
}

View File

@ -1836,7 +1836,7 @@ namespace detail
t.abort();
if ((!t.is_paused() || t.should_request())
&& !t.torrent_file().trackers().empty())
&& !t.trackers().empty())
{
tracker_request req = t.generate_tracker_request();
TORRENT_ASSERT(req.event == tracker_request::stopped);

View File

@ -2760,6 +2760,8 @@ namespace libtorrent
#endif
disconnect_all();
if (!m_paused)
m_just_paused = true;
m_paused = true;
// tell the tracker that we stopped
m_event = tracker_request::stopped;