From 8200f339257b0ca09b7333538f9cac33ea31b192 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 13 Apr 2015 00:50:55 +0000 Subject: [PATCH] fix gcc build issue in test_peer_list --- include/libtorrent/peer_list.hpp | 3 ++- src/peer_list.cpp | 1 + test/test_peer_list.cpp | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/peer_list.hpp b/include/libtorrent/peer_list.hpp index 0bcbc443a..d85c6d796 100644 --- a/include/libtorrent/peer_list.hpp +++ b/include/libtorrent/peer_list.hpp @@ -139,7 +139,8 @@ namespace libtorrent bool new_connection(peer_connection_interface& c, int session_time, torrent_state* state); // 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); void set_connection(torrent_peer* p, peer_connection_interface* c); diff --git a/src/peer_list.cpp b/src/peer_list.cpp index 2678440a2..7e8bff9d7 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -640,6 +640,7 @@ namespace libtorrent if (self_connection) { 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); TORRENT_ASSERT(i->connection == 0); return false; diff --git a/test/test_peer_list.cpp b/test/test_peer_list.cpp index aa03156aa..0133439bc 100644 --- a/test/test_peer_list.cpp +++ b/test/test_peer_list.cpp @@ -57,14 +57,14 @@ struct mock_torrent; struct mock_peer_connection : peer_connection_interface , boost::enable_shared_from_this { - 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_outgoing(out) , m_tp(NULL) , m_remote(remote) , m_local(ep("127.0.0.1", 8080)) , m_disconnect_called(false) - , m_torrent(tor) + , m_torrent(*tor) { for (int i = 0; i < 20; ++i) m_id[i] = rand(); } @@ -122,7 +122,7 @@ struct mock_torrent TORRENT_ASSERT(peerinfo->connection == NULL); if (peerinfo->connection) return false; boost::shared_ptr c - = boost::make_shared(*this, true, peerinfo->ip()); + = boost::make_shared(this, true, peerinfo->ip()); c->set_peer_info(peerinfo); m_connections.push_back(c); @@ -326,7 +326,7 @@ int test_main() t.m_p = &p; TEST_EQUAL(p.num_connect_candidates(), 0); boost::shared_ptr c - = boost::make_shared(t, true, ep("10.0.0.1", 8080)); + = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); p.new_connection(*c, 0, &st); TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_peers(), 1); @@ -353,7 +353,7 @@ int test_main() TEST_EQUAL(p.num_connect_candidates(), 1); boost::shared_ptr c - = boost::make_shared(t, true, ep("10.0.0.1", 8080)); + = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); p.new_connection(*c, 0, &st); TEST_EQUAL(p.num_connect_candidates(), 1); // 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); boost::shared_ptr c - = boost::make_shared(t, true, ep("10.0.0.1", 8080)); + = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); p.new_connection(*c, 0, &st); TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_peers(), 1); @@ -480,7 +480,7 @@ int test_main() TEST_EQUAL(p.num_connect_candidates(), 0); st.erased.clear(); - c = boost::make_shared(t, true, ep("10.0.0.1", 8080)); + c = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); ok = p.new_connection(*c, 0, &st); // since it's banned, we should not allow this incoming connection TEST_EQUAL(ok, false); @@ -727,7 +727,7 @@ int test_main() con_out->set_local_ep(ep("10.0.0.2", 8080)); boost::shared_ptr con_in - = boost::make_shared(t, false, ep("10.0.0.2", 8080)); + = boost::make_shared(&t, false, ep("10.0.0.2", 8080)); con_in->set_local_ep(ep("10.0.0.2", 3000)); p.new_connection(*con_in, 0, &st); @@ -761,7 +761,7 @@ int test_main() // and the incoming connection boost::shared_ptr con_in - = boost::make_shared(t, false, ep("10.0.0.2", 3561)); + = boost::make_shared(&t, false, ep("10.0.0.2", 3561)); con_in->set_local_ep(ep("10.0.0.1", 8080)); p.new_connection(*con_in, 0, &st); @@ -799,7 +799,7 @@ int test_main() //and the incoming connection boost::shared_ptr con_in - = boost::make_shared(t, false, ep("10.0.0.2", 3561)); + = boost::make_shared(&t, false, ep("10.0.0.2", 3561)); con_in->set_local_ep(ep("10.0.0.1", 3000)); p.new_connection(*con_in, 0, &st); @@ -843,7 +843,7 @@ int test_main() TEST_EQUAL(p.num_peers(), 5); boost::shared_ptr con_in - = boost::make_shared(t, false, ep("10.0.1.2", 3561)); + = boost::make_shared(&t, false, ep("10.0.1.2", 3561)); 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