From f7e1d1c1fd31fa1f76f542a291445bee772a3f7f Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 22 Jun 2008 22:00:44 +0000 Subject: [PATCH] piece picker fix --- src/piece_picker.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 5350f00f5..61064e65e 100755 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -1775,7 +1775,13 @@ namespace libtorrent TORRENT_ASSERT(block.piece_index < (int)m_piece_map.size()); TORRENT_ASSERT(block.block_index < blocks_in_piece(block.piece_index)); - TORRENT_ASSERT(m_piece_map[block.piece_index].downloading); + // this might be the case if a piece fails, is restored, and then + // completed from a different peer (from which the piece was requested + // before it failed the hash check) + if (m_piece_map[block.piece_index].downloading == 0) + mark_as_downloading(block, peer, piece_picker::none); + + TORRENT_ASSERT(m_piece_map[block.piece_index].downloaing); std::vector::iterator i = std::find_if(m_downloads.begin(), m_downloads.end(), has_index(block.piece_index));