From 177a7e881c3564f9d8f3dd84384b999b7d560a6e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 31 May 2009 05:50:07 +0000 Subject: [PATCH] fixed handling of dropped request --- ChangeLog | 2 ++ src/peer_connection.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a03bf47a9..698c69d7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -73,6 +73,8 @@ release 0.14.4 * fixed memory leak in disk cache * fixed torrent file path vulnerability * fixed upnp + * fixed bug when dealing with clients that drop requests (i.e. BitComet) + fixes assert as well release 0.14.3 diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 160ed6af0..80667664f 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1939,10 +1939,13 @@ namespace libtorrent pending_block pending_b = *b; #endif - int block_index = b - m_download_queue.begin() - 1; + int block_index = b - m_download_queue.begin(); + TORRENT_ASSERT(m_download_queue[block_index] == pending_b); for (int i = 0; i < block_index; ++i) { pending_block& qe = m_download_queue[i]; + TORRENT_ASSERT(m_download_queue[block_index] == pending_b); + TORRENT_ASSERT(i < block_index); #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING (*m_logger) << time_now_string() @@ -1968,14 +1971,15 @@ namespace libtorrent --i; --block_index; m_outstanding_bytes -= t->block_size(); + TORRENT_ASSERT(m_download_queue[block_index] == pending_b); #if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_DEBUG check_invariant(); #endif } } TORRENT_ASSERT(int(m_download_queue.size()) > block_index + 1); - b = m_download_queue.begin() + (block_index + 1); - TORRENT_ASSERT(b->block == pending_b.block); + b = m_download_queue.begin() + block_index; + TORRENT_ASSERT(*b == pending_b); #ifdef TORRENT_DEBUG TORRENT_ASSERT(m_received_in_piece == p.length);