1395 lt sync
This commit is contained in:
parent
bdf37286cf
commit
33d3ecc5cd
|
@ -274,15 +274,17 @@ namespace libtorrent
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer_connection* connection_for(address const& a)
|
#ifndef NDEBUG
|
||||||
|
void connection_for(address const& a, std::vector<peer_connection*>& pc)
|
||||||
{
|
{
|
||||||
for (peer_iterator i = m_connections.begin()
|
for (peer_iterator i = m_connections.begin()
|
||||||
, end(m_connections.end()); i != end; ++i)
|
, end(m_connections.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
if (i->first.address() == a) return i->second;
|
if (i->first.address() == a) pc.push_back(i->second);
|
||||||
}
|
}
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// the number of peers that belong to this torrent
|
// the number of peers that belong to this torrent
|
||||||
int num_peers() const { return (int)m_connections.size(); }
|
int num_peers() const { return (int)m_connections.size(); }
|
||||||
|
|
|
@ -1262,7 +1262,7 @@ namespace libtorrent
|
||||||
(*m_logger) << time_now_string() << " ==> EXTENSIONS\n";
|
(*m_logger) << time_now_string() << " ==> EXTENSIONS\n";
|
||||||
#endif
|
#endif
|
||||||
assert(m_supports_extensions);
|
assert(m_supports_extensions);
|
||||||
assert(m_sent_handshake && m_sent_bitfield);
|
assert(m_sent_handshake);
|
||||||
|
|
||||||
entry handshake(entry::dictionary_t);
|
entry handshake(entry::dictionary_t);
|
||||||
entry extension_list(entry::dictionary_t);
|
entry extension_list(entry::dictionary_t);
|
||||||
|
|
|
@ -140,14 +140,14 @@ namespace
|
||||||
|
|
||||||
struct match_peer_ip
|
struct match_peer_ip
|
||||||
{
|
{
|
||||||
match_peer_ip(tcp::endpoint const& ip)
|
match_peer_ip(address const& ip)
|
||||||
: m_ip(ip)
|
: m_ip(ip)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator()(policy::peer const& p) const
|
bool operator()(policy::peer const& p) const
|
||||||
{ return p.ip.address() == m_ip.address(); }
|
{ return p.ip.address() == m_ip; }
|
||||||
|
|
||||||
tcp::endpoint const& m_ip;
|
address const& m_ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct match_peer_id
|
struct match_peer_id
|
||||||
|
@ -857,7 +857,7 @@ namespace libtorrent
|
||||||
i = std::find_if(
|
i = std::find_if(
|
||||||
m_peers.begin()
|
m_peers.begin()
|
||||||
, m_peers.end()
|
, m_peers.end()
|
||||||
, match_peer_ip(c.remote()));
|
, match_peer_ip(c.remote().address()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != m_peers.end())
|
if (i != m_peers.end())
|
||||||
|
@ -882,20 +882,28 @@ namespace libtorrent
|
||||||
"connection in favour of this one");
|
"connection in favour of this one");
|
||||||
#endif
|
#endif
|
||||||
i->connection->disconnect();
|
i->connection->disconnect();
|
||||||
|
#ifndef NDEBUG
|
||||||
|
check_invariant();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we don't have ny info about this peer.
|
// we don't have any info about this peer.
|
||||||
// add a new entry
|
// add a new entry
|
||||||
assert(c.remote() == c.get_socket()->remote_endpoint());
|
assert(c.remote() == c.get_socket()->remote_endpoint());
|
||||||
|
|
||||||
peer p(c.remote(), peer::not_connectable, 0);
|
peer p(c.remote(), peer::not_connectable, 0);
|
||||||
m_peers.push_back(p);
|
m_peers.push_back(p);
|
||||||
i = boost::prior(m_peers.end());
|
i = boost::prior(m_peers.end());
|
||||||
|
#ifndef NDEBUG
|
||||||
|
check_invariant();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(m_torrent->connection_for(c.remote()) == &c);
|
||||||
|
|
||||||
c.set_peer_info(&*i);
|
c.set_peer_info(&*i);
|
||||||
assert(i->connection == 0);
|
assert(i->connection == 0);
|
||||||
c.add_stat(i->prev_amount_download, i->prev_amount_upload);
|
c.add_stat(i->prev_amount_download, i->prev_amount_upload);
|
||||||
|
@ -945,7 +953,7 @@ namespace libtorrent
|
||||||
i = std::find_if(
|
i = std::find_if(
|
||||||
m_peers.begin()
|
m_peers.begin()
|
||||||
, m_peers.end()
|
, m_peers.end()
|
||||||
, match_peer_ip(remote));
|
, match_peer_ip(remote.address()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == m_peers.end())
|
if (i == m_peers.end())
|
||||||
|
@ -1232,7 +1240,7 @@ namespace libtorrent
|
||||||
if (c.failed())
|
if (c.failed())
|
||||||
{
|
{
|
||||||
++i->failcount;
|
++i->failcount;
|
||||||
i->connected = time_now();
|
// i->connected = time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the share ratio is 0 (infinite), the
|
// if the share ratio is 0 (infinite), the
|
||||||
|
@ -1308,8 +1316,13 @@ namespace libtorrent
|
||||||
++total_connections;
|
++total_connections;
|
||||||
if (!p.connection) continue;
|
if (!p.connection) continue;
|
||||||
if (!m_torrent->settings().allow_multiple_connections_per_ip)
|
if (!m_torrent->settings().allow_multiple_connections_per_ip)
|
||||||
assert(p.connection == m_torrent->connection_for(p.ip.address())
|
{
|
||||||
|| p.connection == m_torrent->connection_for(p.ip));
|
std::vector<peer_connection*> conns;
|
||||||
|
m_torrent->connection_for(p.ip.address(), conns);
|
||||||
|
assert(std::find_if(conns.begin(), conns.end()
|
||||||
|
, boost::bind(std::equal_to<peer_connection*>(), _1, p.connection))
|
||||||
|
!= conns.end());
|
||||||
|
}
|
||||||
assert(p.connection->peer_info_struct() == 0
|
assert(p.connection->peer_info_struct() == 0
|
||||||
|| p.connection->peer_info_struct() == &p);
|
|| p.connection->peer_info_struct() == &p);
|
||||||
++nonempty_connections;
|
++nonempty_connections;
|
||||||
|
|
|
@ -938,8 +938,14 @@ namespace libtorrent
|
||||||
if (p == 0) continue;
|
if (p == 0) continue;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!settings().allow_multiple_connections_per_ip)
|
if (!settings().allow_multiple_connections_per_ip)
|
||||||
assert(p->connection == 0 || p->connection == connection_for(p->ip.address())
|
{
|
||||||
|| p->connection == connection_for(p->ip));
|
std::vector<peer_connection*> conns;
|
||||||
|
connection_for(p->ip.address(), conns);
|
||||||
|
assert(p->connection == 0
|
||||||
|
|| std::find_if(conns.begin(), conns.end()
|
||||||
|
, boost::bind(std::equal_to<peer_connection*>(), _1, p->connection))
|
||||||
|
!= conns.end());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (p->connection) p->connection->received_invalid_data(index);
|
if (p->connection) p->connection->received_invalid_data(index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue