From e929c58e9f46e68b6f994e316a6eb10f8d282c96 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 1 May 2009 09:42:43 +0000 Subject: [PATCH] fixed bug in ratelimiter's outstanding bytes counter --- include/libtorrent/bandwidth_manager.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index 9c222abe6..e3f7d989a 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -149,6 +149,13 @@ struct bandwidth_manager #ifdef TORRENT_DEBUG void check_invariant() const { + int queued = 0; + for (typename queue_t::const_iterator i = m_queue.begin() + , end(m_queue.end()); i != end; ++i) + { + queued += i->request_size - i->assigned; + } + TORRENT_ASSERT(queued == m_queued_bytes); } #endif @@ -219,6 +226,7 @@ struct bandwidth_manager if (i->assigned == i->request_size || (i->ttl <= 0 && i->assigned > 0)) { + a += i->request_size - i->assigned; TORRENT_ASSERT(i->assigned <= i->request_size); tm.push_back(*i); i = m_queue.erase(i);