From a7e98983d2f664b19227e6ca4126249a915b9160 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 8 Dec 2018 00:39:25 +0100 Subject: [PATCH] remove invalid assert in http_seed_connection --- src/http_seed_connection.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index 40122b92c..486cf85bf 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -113,11 +113,10 @@ namespace libtorrent { } else { - int receive_buffer_size = int(m_recv_buffer.get().size()) - m_parser.body_start(); - // TODO: 1 in chunked encoding mode, this assert won't hold. - // the chunk headers should be subtracted from the receive_buffer_size - TORRENT_ASSERT_VAL(receive_buffer_size <= t->block_size(), receive_buffer_size); - ret.bytes_downloaded = t->block_size() - receive_buffer_size; + int const receive_buffer_size = int(m_recv_buffer.get().size()) - m_parser.body_start(); + // this is an approximation. in chunked encoding mode the chunk headers + // should really be subtracted from the receive_buffer_size + ret.bytes_downloaded = std::max(0, t->block_size() - receive_buffer_size); } // this is used to make sure that the block_index stays within // bounds. If the entire piece is downloaded, the block_index