From 1399b623bc16276a34fcfa50d71c601f517b200f Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 21 Aug 2007 21:51:29 +0000 Subject: [PATCH] choke count fixes --- src/session_impl.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f2e2ac806..2b069ba65 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1123,6 +1123,8 @@ namespace detail assert(p->peer_info_struct()); if (!p->is_choked() && !p->peer_info_struct()->optimistically_unchoked) t->choke_peer(*p); + if (!p->is_choked()) + ++m_num_unchoked; } } @@ -1177,6 +1179,10 @@ namespace detail current_optimistic_unchoke->second->peer_info_struct()->optimistically_unchoked = false; t->choke_peer(*current_optimistic_unchoke->second); } + else + { + ++m_num_unchoked; + } torrent* t = optimistic_unchoke_candidate->second->associated_torrent().lock().get(); assert(t); @@ -1184,9 +1190,6 @@ namespace detail assert(ret); optimistic_unchoke_candidate->second->peer_info_struct()->optimistically_unchoked = true; } - - if (optimistic_unchoke_candidate != m_connections.end()) - ++m_num_unchoked; } } @@ -2197,7 +2200,10 @@ namespace detail } } assert(num_optimistic == 0 || num_optimistic == 1); - assert(m_num_unchoked == unchokes); + if (m_num_unchoked != unchokes) + { + assert(false); + } } #endif