From cbcf8df5048c4a035786e69ac84779f8feb0e36c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 1 Oct 2005 11:20:47 +0000 Subject: [PATCH] modified some assertions in policy --- src/policy.cpp | 2 +- src/torrent.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/policy.cpp b/src/policy.cpp index d9dccd2a0..a819fbea9 100755 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -1289,7 +1289,7 @@ namespace libtorrent // so in the destructor of new_connection this // case will be used. assert(connected_peers == num_torrent_peers - || connected_peers - 1 == num_torrent_peers); + || connected_peers == num_torrent_peers - 1); // TODO: Make sure the number of peers in m_torrent is equal // to the number of connected peers in m_peers. diff --git a/src/torrent.cpp b/src/torrent.cpp index b3afa2a0c..f3b44e69d 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -853,6 +853,9 @@ namespace libtorrent m_policy->connection_closed(*p); m_connections.erase(i); +#ifndef NDEBUG + m_policy->check_invariant(); +#endif } peer_connection& torrent::connect_to_peer(const address& a) @@ -868,12 +871,20 @@ namespace libtorrent // add the newly connected peer to this torrent's peer list assert(m_connections.find(p->second->get_socket()->sender()) == m_connections.end()); - + +#ifndef NDEBUG + m_policy->check_invariant(); +#endif + m_connections.insert( std::make_pair( p->second->get_socket()->sender() , boost::get_pointer(p->second))); +#ifndef NDEBUG + m_policy->check_invariant(); +#endif + m_ses.m_selector.monitor_readability(s); m_ses.m_selector.monitor_errors(s); return *c; @@ -889,9 +900,13 @@ namespace libtorrent = m_ses.m_connections.find(p->get_socket()); assert(i != m_ses.m_connections.end()); - m_policy->new_connection(*i->second); +#ifndef NDEBUG + m_policy->check_invariant(); +#endif m_connections.insert(std::make_pair(p->get_socket()->sender(), p)); + + m_policy->new_connection(*i->second); } void torrent::disconnect_all()