From 16d56eaee6767242a3bd1b53ccb14f2f3d8ffee8 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 15 Oct 2008 17:31:20 +0000 Subject: [PATCH] clears torrent stats when paused --- include/libtorrent/stat.hpp | 14 ++++++++++++++ src/torrent.cpp | 1 + 2 files changed, 15 insertions(+) diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index ef4fdd04a..d99593a1e 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -87,6 +87,14 @@ namespace libtorrent size_type counter() const { return m_counter; } + void clear() + { + std::memset(m_rate_history, 0, sizeof(m_rate_history)); + m_counter = 0; + m_total_counter = 0; + m_rate_sum = 0; + } + private: #ifndef NDEBUG @@ -306,6 +314,12 @@ namespace libtorrent num_channels }; + void clear() + { + for (int i = 0; i < num_channels; ++i) + m_stat[i].clear(); + } + private: stat_channel m_stat[num_channels]; diff --git a/src/torrent.cpp b/src/torrent.cpp index caadd1521..601236263 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -4112,6 +4112,7 @@ namespace libtorrent { // tell the tracker that we're back m_start_sent = false; + m_stat.clear(); announce_with_tracker(); }