added more asserts related to recent downloading_piece optimization and fixed a translation problem to the public interface
This commit is contained in:
parent
3bdf01778a
commit
b20270d243
|
@ -272,6 +272,16 @@ namespace libtorrent
|
|||
return i->second;
|
||||
}
|
||||
|
||||
peer_connection* connection_for(address const& a)
|
||||
{
|
||||
for (peer_iterator i = m_connections.begin()
|
||||
, end(m_connections.end()); i != end; ++i)
|
||||
{
|
||||
if (i->first.address() == a) return i->second;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// the number of peers that belong to this torrent
|
||||
int num_peers() const { return (int)m_connections.size(); }
|
||||
int num_seeds() const;
|
||||
|
|
|
@ -56,6 +56,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/aux_/session_impl.hpp"
|
||||
#include "libtorrent/piece_picker.hpp"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include "libtorrent/bt_peer_connection.hpp"
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
class peer_connection;
|
||||
|
@ -190,6 +194,7 @@ namespace libtorrent
|
|||
{
|
||||
assert(!t.is_seed());
|
||||
assert(!c.has_peer_choked());
|
||||
assert(c.peer_info_struct() != 0 || !dynamic_cast<bt_peer_connection*>(&c));
|
||||
int num_requests = c.desired_queue_size()
|
||||
- (int)c.download_queue().size()
|
||||
- (int)c.request_queue().size();
|
||||
|
@ -1399,17 +1404,20 @@ namespace libtorrent
|
|||
for (const_iterator i = m_peers.begin();
|
||||
i != m_peers.end(); ++i)
|
||||
{
|
||||
peer const& p = *i;
|
||||
if (!m_torrent->settings().allow_multiple_connections_per_ip)
|
||||
assert(unique_test.find(i->ip.address()) == unique_test.end());
|
||||
unique_test.insert(i->ip.address());
|
||||
assert(unique_test.find(p.ip.address()) == unique_test.end());
|
||||
unique_test.insert(p.ip.address());
|
||||
++total_connections;
|
||||
if (!i->connection) continue;
|
||||
assert(i->connection->peer_info_struct() == 0
|
||||
|| i->connection->peer_info_struct() == &*i);
|
||||
if (!p.connection) continue;
|
||||
if (!m_torrent->settings().allow_multiple_connections_per_ip)
|
||||
assert(p.connection == m_torrent->connection_for(p.ip.address()));
|
||||
assert(p.connection->peer_info_struct() == 0
|
||||
|| p.connection->peer_info_struct() == &p);
|
||||
++nonempty_connections;
|
||||
if (!i->connection->is_disconnecting())
|
||||
if (!p.connection->is_disconnecting())
|
||||
++connected_peers;
|
||||
if (!i->connection->is_choked()) ++actual_unchoked;
|
||||
if (!p.connection->is_choked()) ++actual_unchoked;
|
||||
}
|
||||
// assert(actual_unchoked <= m_torrent->m_uploads_quota.given);
|
||||
assert(actual_unchoked == m_num_unchoked);
|
||||
|
|
|
@ -937,8 +937,8 @@ namespace libtorrent
|
|||
policy::peer* p = static_cast<policy::peer*>(*i);
|
||||
if (p == 0) continue;
|
||||
#ifndef NDEBUG
|
||||
peer_iterator pi = m_connections.find(p->ip);
|
||||
assert((pi != m_connections.end()) == bool(p->connection));
|
||||
if (!settings().allow_multiple_connections_per_ip)
|
||||
assert(p->connection == 0 || p->connection == connection_for(p->ip.address()));
|
||||
#endif
|
||||
if (p->connection) p->connection->received_invalid_data(index);
|
||||
|
||||
|
@ -1897,6 +1897,8 @@ namespace libtorrent
|
|||
if (pp) p->add_extension(pp);
|
||||
}
|
||||
#endif
|
||||
assert(connection_for(p->remote()) == p);
|
||||
assert(ci->second == p);
|
||||
m_policy->new_connection(*ci->second);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
|
|
@ -776,7 +776,13 @@ namespace libtorrent
|
|||
if (i->info[j].peer == 0)
|
||||
pi.blocks[j].peer = tcp::endpoint();
|
||||
else
|
||||
pi.blocks[j].peer = static_cast<policy::peer*>(i->info[j].peer)->ip;
|
||||
{
|
||||
policy::peer* p = static_cast<policy::peer*>(i->info[j].peer);
|
||||
if (p->connection)
|
||||
pi.blocks[j].peer = p->connection->remote();
|
||||
else
|
||||
pi.blocks[j].peer = p->ip;
|
||||
}
|
||||
|
||||
pi.blocks[j].num_downloads = i->info[j].num_downloads;
|
||||
pi.blocks[j].state = i->info[j].state;
|
||||
|
|
Loading…
Reference in New Issue