fix bug in policy::erase_peers and simplified the logic some

This commit is contained in:
Arvid Norberg 2011-11-28 09:55:00 +00:00
parent 47e81ff90b
commit 27b25017f2
1 changed files with 17 additions and 19 deletions

View File

@ -507,31 +507,29 @@ namespace libtorrent
peer& pe = *m_peers[round_robin];
int current = round_robin;
if (is_erase_candidate(pe, m_finished)
&& (erase_candidate == -1
|| !compare_peer_erase(*m_peers[erase_candidate], pe)))
{
if (is_erase_candidate(pe, m_finished)
&& (erase_candidate == -1
|| !compare_peer_erase(*m_peers[erase_candidate], pe)))
if (should_erase_immediately(pe))
{
if (should_erase_immediately(pe))
{
if (erase_candidate > current) --erase_candidate;
if (force_erase_candidate > current) --force_erase_candidate;
TORRENT_ASSERT(current >= 0 && current < int(m_peers.size()));
--round_robin;
erase_peer(m_peers.begin() + current);
}
else
{
erase_candidate = current;
}
if (erase_candidate > current) --erase_candidate;
if (force_erase_candidate > current) --force_erase_candidate;
TORRENT_ASSERT(current >= 0 && current < int(m_peers.size()));
erase_peer(m_peers.begin() + current);
continue;
}
if (is_force_erase_candidate(pe)
&& (force_erase_candidate == -1
|| !compare_peer_erase(*m_peers[force_erase_candidate], pe)))
else
{
force_erase_candidate = current;
erase_candidate = current;
}
}
if (is_force_erase_candidate(pe)
&& (force_erase_candidate == -1
|| !compare_peer_erase(*m_peers[force_erase_candidate], pe)))
{
force_erase_candidate = current;
}
++round_robin;
}