From 5642a0bd59c907d427aa4f8592b882b6cb826820 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 17 Jun 2014 08:07:03 +0000 Subject: [PATCH] fix outstanding bytes issue when receiving redundant bytes --- src/peer_connection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 66c1a585e..78235b896 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2387,6 +2387,16 @@ namespace libtorrent m_received_in_piece = 0; #endif t->add_redundant_bytes(p.length, torrent::piece_unknown); + + // the bytes of the piece we just completed have been deducted from + // m_outstanding_bytes as we received it, in incoming_piece_fragment. + // however, it now turns out the piece we received wasn't in the + // download queue, so we still have the same number of pieces in the + // download queue, which is why we need to add the bytes back. + m_outstanding_bytes += p.length; +#if TORRENT_USE_INVARIANT_CHECKS + check_invariant(); +#endif return; }