fix issue introduced with updated disconnect-redundant logic for metadata-only seeding
This commit is contained in:
parent
d7d4da5b80
commit
d5f51f60ab
|
@ -3115,21 +3115,19 @@ namespace libtorrent
|
||||||
// increase the trust point of all peers that sent
|
// increase the trust point of all peers that sent
|
||||||
// parts of this piece.
|
// parts of this piece.
|
||||||
std::set<void*> peers;
|
std::set<void*> peers;
|
||||||
std::copy(downloaders.begin(), downloaders.end(), std::inserter(peers, peers.begin()));
|
|
||||||
|
|
||||||
we_have(index);
|
// these policy::peer pointers are owned by m_policy and they may be
|
||||||
|
// invalidated if a peer disconnects. We cannot keep them across any
|
||||||
for (peer_iterator i = m_connections.begin(); i != m_connections.end();)
|
// significant operations, but we should use them right away
|
||||||
{
|
// ignore NULL pointers
|
||||||
intrusive_ptr<peer_connection> p = *i;
|
std::remove_copy(downloaders.begin(), downloaders.end()
|
||||||
++i;
|
, std::inserter(peers, peers.begin()), (policy::peer*)0);
|
||||||
p->announce_piece(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (std::set<void*>::iterator i = peers.begin()
|
for (std::set<void*>::iterator i = peers.begin()
|
||||||
, end(peers.end()); i != end; ++i)
|
, end(peers.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
policy::peer* p = static_cast<policy::peer*>(*i);
|
policy::peer* p = static_cast<policy::peer*>(*i);
|
||||||
|
TORRENT_ASSERT(p != 0);
|
||||||
if (p == 0) continue;
|
if (p == 0) continue;
|
||||||
TORRENT_ASSERT(p->in_use);
|
TORRENT_ASSERT(p->in_use);
|
||||||
p->on_parole = false;
|
p->on_parole = false;
|
||||||
|
@ -3144,6 +3142,21 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// announcing a piece may invalidate the policy::peer pointers
|
||||||
|
// so we can't use them anymore
|
||||||
|
|
||||||
|
downloaders.clear();
|
||||||
|
peers.clear();
|
||||||
|
|
||||||
|
we_have(index);
|
||||||
|
|
||||||
|
for (peer_iterator i = m_connections.begin(); i != m_connections.end();)
|
||||||
|
{
|
||||||
|
intrusive_ptr<peer_connection> p = *i;
|
||||||
|
++i;
|
||||||
|
p->announce_piece(index);
|
||||||
|
}
|
||||||
|
|
||||||
if (settings().max_sparse_regions > 0
|
if (settings().max_sparse_regions > 0
|
||||||
&& m_picker->sparse_regions() > settings().max_sparse_regions)
|
&& m_picker->sparse_regions() > settings().max_sparse_regions)
|
||||||
{
|
{
|
||||||
|
@ -5579,6 +5592,11 @@ namespace libtorrent
|
||||||
// any of the peers.
|
// any of the peers.
|
||||||
m_override_resume_data = true;
|
m_override_resume_data = true;
|
||||||
|
|
||||||
|
// we have to initialize the torrent before we start
|
||||||
|
// disconnecting redundant peers, otherwise we'll think
|
||||||
|
// we're a seed, because we have all 0 pieces
|
||||||
|
init();
|
||||||
|
|
||||||
// disconnect redundant peers
|
// disconnect redundant peers
|
||||||
for (std::set<peer_connection*>::iterator i = m_connections.begin()
|
for (std::set<peer_connection*>::iterator i = m_connections.begin()
|
||||||
, end(m_connections.end()); i != end;)
|
, end(m_connections.end()); i != end;)
|
||||||
|
@ -5587,8 +5605,6 @@ namespace libtorrent
|
||||||
(*p)->disconnect_if_redundant();
|
(*p)->disconnect_if_redundant();
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue