added some invariant checks to bt_peer_connection

This commit is contained in:
Arvid Norberg 2009-11-29 19:38:32 +00:00
parent ea1043a293
commit 1c63a0e032
1 changed files with 11 additions and 0 deletions

View File

@ -3035,6 +3035,17 @@ namespace libtorrent
#ifdef TORRENT_DEBUG
void bt_peer_connection::check_invariant() const
{
boost::shared_ptr<torrent> 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());