removes peers from bandwidth request queue when disconnecting

This commit is contained in:
Arvid Norberg 2008-01-06 00:58:51 +00:00
parent 6c364731a9
commit 1c816fa608
1 changed files with 15 additions and 0 deletions

View File

@ -1619,6 +1619,18 @@ namespace libtorrent
p->set_peer_info(0);
TORRENT_ASSERT(i != m_connections.end());
m_connections.erase(i);
// remove from bandwidth request-queue
for (int c = 0; c < 2; ++c)
{
for (queue_t::iterator i = m_bandwidth_queue[c].begin()
, end(m_bandwidth_queue[c].end()); i != end; ++i)
{
if (i->peer != p) continue;
m_bandwidth_queue[c].erase(i);
break;
}
}
}
catch (std::exception& e)
{
@ -2644,6 +2656,9 @@ namespace libtorrent
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
TORRENT_ASSERT(m_bandwidth_queue[0].size() <= m_connections.size());
TORRENT_ASSERT(m_bandwidth_queue[1].size() <= m_connections.size());
int num_uploads = 0;
std::map<piece_block, int> num_requests;
for (const_peer_iterator i = begin(); i != end(); ++i)