From c883f4475c6c320e96bd35fab9aeb546e395ef6a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 3 Jun 2008 05:21:00 +0000 Subject: [PATCH] saves statistics from the last second from peer connections that are disconnected. Partly fixes #339 --- include/libtorrent/torrent.hpp | 1 + src/peer_connection.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index dec649c24..30f59b523 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -180,6 +180,7 @@ namespace libtorrent std::string name() const; stat statistics() const { return m_stat; } + void add_stats(stat const& s) { m_stat += s; } size_type bytes_left() const; boost::tuples::tuple bytes_done() const; size_type quantized_bytes_done() const; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 1a72ca148..29adfcfe2 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2218,6 +2218,10 @@ namespace libtorrent if (t) { + // make sure we keep all the stats! + calc_ip_overhead(); + t->add_stats(statistics()); + if (t->has_picker()) { piece_picker& picker = t->picker();