diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 78397b6dd..b05141f7c 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2220,7 +2220,7 @@ namespace libtorrent if (t->alerts().should_post()) { t->alerts().post_alert(unwanted_block_alert(t->get_handle(), m_remote - , m_peer_id, block_finished.block_index, block_finished.piece_index)); + , m_peer_id, block_finished.block_index, block_finished.piece_index)); } #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING (*m_logger) << " *** The block we just got was not in the " diff --git a/src/policy.cpp b/src/policy.cpp index 7bd75418b..aaa663687 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -731,6 +731,7 @@ namespace libtorrent { c.disconnect(errors::self_connection, 1); i->connection->disconnect(errors::self_connection, 1); + TORRENT_ASSERT(i->connection == 0); return false; } @@ -740,6 +741,7 @@ namespace libtorrent if (ec2) { i->connection->disconnect(ec2); + TORRENT_ASSERT(i->connection == 0); } else if (!i->connection->is_connecting() || c.is_local()) { @@ -754,6 +756,7 @@ namespace libtorrent "connection in favour of this one"); #endif i->connection->disconnect(errors::duplicate_peer_id); + TORRENT_ASSERT(i->connection == 0); } } @@ -835,6 +838,7 @@ namespace libtorrent // this cannot be a connect candidate anymore, since i->connection is set TORRENT_ASSERT(!is_connect_candidate(*i, m_finished)); + TORRENT_ASSERT(has_connection(&c)); return true; } @@ -1263,11 +1267,13 @@ namespace libtorrent // if we're not a seed, but we have too many peers // start weeding the ones we only know from resume // data first - if (m_torrent->is_seed() || m_peers.size() >= m_torrent->settings().max_peerlist_size * 0.9) - { - if (p->source == peer_info::resume_data) - erase_peer(p); - } + // at this point it may be tempting to erase peers + // from the peer list, but keep in mind that we might + // have gotten to this point through new_connection, just + // disconnecting an old peer, relying on this policy::peer + // to still exist when we get back there, to assign the new + // peer connection pointer to it. The peer list must + // be left intact. } void policy::peer_is_interesting(peer_connection& c)