bandwidth manager fix

This commit is contained in:
Arvid Norberg 2007-12-09 18:44:26 +00:00
parent c50d08f75f
commit f06bf0d440
1 changed files with 9 additions and 2 deletions

View File

@ -225,8 +225,14 @@ struct bandwidth_manager
} }
#endif #endif
TORRENT_ASSERT(peer->max_assignable_bandwidth(m_channel) > 0);
boost::shared_ptr<Torrent> t = peer->associated_torrent().lock(); 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)); m_queue.push_back(bw_queue_entry<PeerConnection>(peer, blk, non_prioritized));
if (!non_prioritized) if (!non_prioritized)
{ {
@ -389,6 +395,7 @@ private:
if (max_assignable == 0) if (max_assignable == 0)
{ {
t->expire_bandwidth(m_channel, qe.max_block_size); t->expire_bandwidth(m_channel, qe.max_block_size);
qe.peer->assign_bandwidth(m_channel, 0);
TORRENT_ASSERT(amount == limit - m_current_quota); TORRENT_ASSERT(amount == limit - m_current_quota);
continue; continue;
} }