fix gcc build issue in test_peer_list

This commit is contained in:
Arvid Norberg 2015-04-13 00:50:55 +00:00
parent daacbbfbb4
commit 8200f33925
3 changed files with 14 additions and 12 deletions

View File

@ -139,7 +139,8 @@ namespace libtorrent
bool new_connection(peer_connection_interface& c, int session_time, torrent_state* state); bool new_connection(peer_connection_interface& c, int session_time, torrent_state* state);
// the given connection was just closed // the given connection was just closed
void connection_closed(const peer_connection_interface& c, int session_time, torrent_state* state); void connection_closed(const peer_connection_interface& c
, int session_time, torrent_state* state);
bool ban_peer(torrent_peer* p); bool ban_peer(torrent_peer* p);
void set_connection(torrent_peer* p, peer_connection_interface* c); void set_connection(torrent_peer* p, peer_connection_interface* c);

View File

@ -640,6 +640,7 @@ namespace libtorrent
if (self_connection) if (self_connection)
{ {
c.disconnect(errors::self_connection, op_bittorrent, 1); c.disconnect(errors::self_connection, op_bittorrent, 1);
TORRENT_ASSERT(i->connection->peer_info_struct() == i);
i->connection->disconnect(errors::self_connection, op_bittorrent, 1); i->connection->disconnect(errors::self_connection, op_bittorrent, 1);
TORRENT_ASSERT(i->connection == 0); TORRENT_ASSERT(i->connection == 0);
return false; return false;

View File

@ -57,14 +57,14 @@ struct mock_torrent;
struct mock_peer_connection : peer_connection_interface struct mock_peer_connection : peer_connection_interface
, boost::enable_shared_from_this<mock_peer_connection> , boost::enable_shared_from_this<mock_peer_connection>
{ {
mock_peer_connection(mock_torrent& tor, bool out, tcp::endpoint const& remote) mock_peer_connection(mock_torrent* tor, bool out, tcp::endpoint const& remote)
: m_choked(false) : m_choked(false)
, m_outgoing(out) , m_outgoing(out)
, m_tp(NULL) , m_tp(NULL)
, m_remote(remote) , m_remote(remote)
, m_local(ep("127.0.0.1", 8080)) , m_local(ep("127.0.0.1", 8080))
, m_disconnect_called(false) , m_disconnect_called(false)
, m_torrent(tor) , m_torrent(*tor)
{ {
for (int i = 0; i < 20; ++i) m_id[i] = rand(); for (int i = 0; i < 20; ++i) m_id[i] = rand();
} }
@ -122,7 +122,7 @@ struct mock_torrent
TORRENT_ASSERT(peerinfo->connection == NULL); TORRENT_ASSERT(peerinfo->connection == NULL);
if (peerinfo->connection) return false; if (peerinfo->connection) return false;
boost::shared_ptr<mock_peer_connection> c boost::shared_ptr<mock_peer_connection> c
= boost::make_shared<mock_peer_connection>(*this, true, peerinfo->ip()); = boost::make_shared<mock_peer_connection>(this, true, peerinfo->ip());
c->set_peer_info(peerinfo); c->set_peer_info(peerinfo);
m_connections.push_back(c); m_connections.push_back(c);
@ -326,7 +326,7 @@ int test_main()
t.m_p = &p; t.m_p = &p;
TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_connect_candidates(), 0);
boost::shared_ptr<mock_peer_connection> c boost::shared_ptr<mock_peer_connection> c
= boost::make_shared<mock_peer_connection>(t, true, ep("10.0.0.1", 8080)); = boost::make_shared<mock_peer_connection>(&t, true, ep("10.0.0.1", 8080));
p.new_connection(*c, 0, &st); p.new_connection(*c, 0, &st);
TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_connect_candidates(), 0);
TEST_EQUAL(p.num_peers(), 1); TEST_EQUAL(p.num_peers(), 1);
@ -353,7 +353,7 @@ int test_main()
TEST_EQUAL(p.num_connect_candidates(), 1); TEST_EQUAL(p.num_connect_candidates(), 1);
boost::shared_ptr<mock_peer_connection> c boost::shared_ptr<mock_peer_connection> c
= boost::make_shared<mock_peer_connection>(t, true, ep("10.0.0.1", 8080)); = boost::make_shared<mock_peer_connection>(&t, true, ep("10.0.0.1", 8080));
p.new_connection(*c, 0, &st); p.new_connection(*c, 0, &st);
TEST_EQUAL(p.num_connect_candidates(), 1); TEST_EQUAL(p.num_connect_candidates(), 1);
// at this point we have two peers, because we think they have different // at this point we have two peers, because we think they have different
@ -460,7 +460,7 @@ int test_main()
TEST_EQUAL(p.num_connect_candidates(), 1); TEST_EQUAL(p.num_connect_candidates(), 1);
boost::shared_ptr<mock_peer_connection> c boost::shared_ptr<mock_peer_connection> c
= boost::make_shared<mock_peer_connection>(t, true, ep("10.0.0.1", 8080)); = boost::make_shared<mock_peer_connection>(&t, true, ep("10.0.0.1", 8080));
p.new_connection(*c, 0, &st); p.new_connection(*c, 0, &st);
TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_connect_candidates(), 0);
TEST_EQUAL(p.num_peers(), 1); TEST_EQUAL(p.num_peers(), 1);
@ -480,7 +480,7 @@ int test_main()
TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_connect_candidates(), 0);
st.erased.clear(); st.erased.clear();
c = boost::make_shared<mock_peer_connection>(t, true, ep("10.0.0.1", 8080)); c = boost::make_shared<mock_peer_connection>(&t, true, ep("10.0.0.1", 8080));
ok = p.new_connection(*c, 0, &st); ok = p.new_connection(*c, 0, &st);
// since it's banned, we should not allow this incoming connection // since it's banned, we should not allow this incoming connection
TEST_EQUAL(ok, false); TEST_EQUAL(ok, false);
@ -727,7 +727,7 @@ int test_main()
con_out->set_local_ep(ep("10.0.0.2", 8080)); con_out->set_local_ep(ep("10.0.0.2", 8080));
boost::shared_ptr<mock_peer_connection> con_in boost::shared_ptr<mock_peer_connection> con_in
= boost::make_shared<mock_peer_connection>(t, false, ep("10.0.0.2", 8080)); = boost::make_shared<mock_peer_connection>(&t, false, ep("10.0.0.2", 8080));
con_in->set_local_ep(ep("10.0.0.2", 3000)); con_in->set_local_ep(ep("10.0.0.2", 3000));
p.new_connection(*con_in, 0, &st); p.new_connection(*con_in, 0, &st);
@ -761,7 +761,7 @@ int test_main()
// and the incoming connection // and the incoming connection
boost::shared_ptr<mock_peer_connection> con_in boost::shared_ptr<mock_peer_connection> con_in
= boost::make_shared<mock_peer_connection>(t, false, ep("10.0.0.2", 3561)); = boost::make_shared<mock_peer_connection>(&t, false, ep("10.0.0.2", 3561));
con_in->set_local_ep(ep("10.0.0.1", 8080)); con_in->set_local_ep(ep("10.0.0.1", 8080));
p.new_connection(*con_in, 0, &st); p.new_connection(*con_in, 0, &st);
@ -799,7 +799,7 @@ int test_main()
//and the incoming connection //and the incoming connection
boost::shared_ptr<mock_peer_connection> con_in boost::shared_ptr<mock_peer_connection> con_in
= boost::make_shared<mock_peer_connection>(t, false, ep("10.0.0.2", 3561)); = boost::make_shared<mock_peer_connection>(&t, false, ep("10.0.0.2", 3561));
con_in->set_local_ep(ep("10.0.0.1", 3000)); con_in->set_local_ep(ep("10.0.0.1", 3000));
p.new_connection(*con_in, 0, &st); p.new_connection(*con_in, 0, &st);
@ -843,7 +843,7 @@ int test_main()
TEST_EQUAL(p.num_peers(), 5); TEST_EQUAL(p.num_peers(), 5);
boost::shared_ptr<mock_peer_connection> con_in boost::shared_ptr<mock_peer_connection> con_in
= boost::make_shared<mock_peer_connection>(t, false, ep("10.0.1.2", 3561)); = boost::make_shared<mock_peer_connection>(&t, false, ep("10.0.1.2", 3561));
con_in->set_local_ep(ep("10.0.2.1", 3000)); con_in->set_local_ep(ep("10.0.2.1", 3000));
// since we're already at 5 peers in the peer list, this call should // since we're already at 5 peers in the peer list, this call should