fix to recalculate_connect_candidates
This commit is contained in:
parent
7439ca3277
commit
c71100950b
|
@ -308,11 +308,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int num_seeds() const { return m_num_seeds; }
|
int num_seeds() const { return m_num_seeds; }
|
||||||
int num_connect_candidates() const { return m_num_connect_candidates; }
|
int num_connect_candidates() const { return m_num_connect_candidates; }
|
||||||
void recalculate_connect_candidates()
|
void recalculate_connect_candidates();
|
||||||
{
|
|
||||||
if (m_num_connect_candidates == 0)
|
|
||||||
m_num_connect_candidates = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void erase_peer(iterator i);
|
void erase_peer(iterator i);
|
||||||
|
|
||||||
|
|
|
@ -375,6 +375,8 @@ namespace libtorrent
|
||||||
// as well, such as in the piece picker.
|
// as well, such as in the piece picker.
|
||||||
void policy::erase_peer(iterator i)
|
void policy::erase_peer(iterator i)
|
||||||
{
|
{
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (m_torrent->has_picker())
|
if (m_torrent->has_picker())
|
||||||
m_torrent->picker().clear_peer((void*)&(*i));
|
m_torrent->picker().clear_peer((void*)&(*i));
|
||||||
if (i->seed) --m_num_seeds;
|
if (i->seed) --m_num_seeds;
|
||||||
|
@ -1069,6 +1071,17 @@ namespace libtorrent
|
||||||
c.send_block_requests();
|
c.send_block_requests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void policy::recalculate_connect_candidates()
|
||||||
|
{
|
||||||
|
m_num_connect_candidates = 0;
|
||||||
|
const bool is_finished = m_torrent->is_finished();
|
||||||
|
for (const_iterator i = m_peers.begin();
|
||||||
|
i != m_peers.end(); ++i)
|
||||||
|
{
|
||||||
|
m_num_connect_candidates += is_connect_candidate(*i, is_finished);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
bool policy::has_connection(const peer_connection* c)
|
bool policy::has_connection(const peer_connection* c)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue