fix in the smart_ban to not use invalid pointers
This commit is contained in:
parent
b2a49d2db9
commit
8a47c849ce
|
@ -226,6 +226,8 @@ namespace libtorrent
|
||||||
bool connect_one_peer();
|
bool connect_one_peer();
|
||||||
bool disconnect_one_peer();
|
bool disconnect_one_peer();
|
||||||
|
|
||||||
|
bool has_peer(policy::peer const* p) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
bool unchoke_one_peer();
|
bool unchoke_one_peer();
|
||||||
|
|
|
@ -1035,6 +1035,17 @@ namespace libtorrent
|
||||||
p->source |= src;
|
p->source |= src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool policy::has_peer(policy::peer const* p) const
|
||||||
|
{
|
||||||
|
// find p in m_peers
|
||||||
|
for (std::multimap<address, peer>::const_iterator i = m_peers.begin()
|
||||||
|
, end(m_peers.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
if (&i->second == p) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
policy::peer* policy::peer_from_tracker(tcp::endpoint const& remote, peer_id const& pid
|
policy::peer* policy::peer_from_tracker(tcp::endpoint const& remote, peer_id const& pid
|
||||||
, int src, char flags)
|
, int src, char flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -186,8 +186,8 @@ namespace libtorrent { namespace
|
||||||
// from the first time it sent it
|
// from the first time it sent it
|
||||||
// at least one of them must be bad
|
// at least one of them must be bad
|
||||||
|
|
||||||
// TODO: make sure p is still a valid pointer
|
|
||||||
if (p == 0) return;
|
if (p == 0) return;
|
||||||
|
if (!m_torrent.get_policy().has_peer(p)) return;
|
||||||
|
|
||||||
#ifdef TORRENT_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
char const* client = "-";
|
char const* client = "-";
|
||||||
|
@ -248,8 +248,8 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
policy::peer* p = b.second.peer;
|
policy::peer* p = b.second.peer;
|
||||||
|
|
||||||
// TODO: make sure p is still a valid pointer
|
|
||||||
if (p == 0) return;
|
if (p == 0) return;
|
||||||
|
if (!m_torrent.get_policy().has_peer(p)) return;
|
||||||
|
|
||||||
#ifdef TORRENT_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
char const* client = "-";
|
char const* client = "-";
|
||||||
|
|
Loading…
Reference in New Issue