From 1c63a0e03212d4563dd9efe1486ec1a6c9fdca3c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 29 Nov 2009 19:38:32 +0000 Subject: [PATCH] added some invariant checks to bt_peer_connection --- src/bt_peer_connection.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index d0d25f414..8434ce840 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -3035,6 +3035,17 @@ namespace libtorrent #ifdef TORRENT_DEBUG void bt_peer_connection::check_invariant() const { + boost::shared_ptr t = associated_torrent().lock(); + + if (!m_disconnect_started && m_initialized) + { + // none of this matters if we're disconnecting anyway + if (t->is_finished()) + TORRENT_ASSERT(!is_interesting()); + if (is_seed()) + TORRENT_ASSERT(upload_only()); + } + #ifndef TORRENT_DISABLE_ENCRYPTION TORRENT_ASSERT( (bool(m_state != read_pe_dhkey) || m_dh_key_exchange.get()) || !is_local());