From 71fb640699233b160dd0b194f47c7dc54bd1f4f9 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 6 Nov 2008 09:01:27 +0000 Subject: [PATCH] fix to count download stats when a peer has disconnected or sends an invalid message id --- src/bt_peer_connection.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 485072549..c5f663c0a 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -1339,7 +1339,11 @@ namespace libtorrent TORRENT_ASSERT(received > 0); // this means the connection has been closed already - if (associated_torrent().expired()) return false; + if (associated_torrent().expired()) + { + m_statistics.received_bytes(0, received); + return false; + } buffer::const_interval recv_buffer = receive_buffer(); @@ -1360,6 +1364,7 @@ namespace libtorrent } #endif + m_statistics.received_bytes(0, received); std::stringstream msg; msg << "unkown message id: " << packet_type << " size: " << packet_size(); disconnect(msg.str().c_str(), 2);