From 5ae074994d730f828c3b7a7c49d4738b8ae65507 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 20 Oct 2013 07:10:09 +0000 Subject: [PATCH] revert a bad optimization from peer_connection's invariant check --- src/peer_connection.cpp | 14 ++++---------- src/piece_picker.cpp | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 237ebe617..ae478380e 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5883,7 +5883,6 @@ namespace libtorrent // num_requests[i->block].peers.push_back(&p); } } - piece_picker::downloading_piece last_piece; for (std::map::iterator i = num_requests.begin() , end(num_requests.end()); i != end; ++i) { @@ -5894,18 +5893,12 @@ namespace libtorrent int count_with_nowant = pc.num_peers_with_nowant; (void)count_with_timeouts; (void)count_with_nowant; - if (b.piece_index != last_piece.index) - t->picker().piece_info(b.piece_index, last_piece); - - // has b been downloaded? - if ((last_piece.finished == 0 && last_piece.writing == 0) - || (last_piece.info && last_piece.info[b.block_index].state >= piece_picker::block_info::state_writing)) - { - int picker_count = t->picker().num_peers(b); + int picker_count = t->picker().num_peers(b); + if (!t->picker().is_downloaded(b)) TORRENT_ASSERT(picker_count == count); - } } } +#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS if (m_peer_info && type() == bittorrent_connection) { policy::const_iterator i = t->get_policy().begin_peer(); @@ -5916,6 +5909,7 @@ namespace libtorrent } TORRENT_ASSERT(i != end); } +#endif if (t->has_picker() && !t->is_aborted()) { // make sure that pieces that have completed the download diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 5eeb60936..326b34975 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -142,7 +142,7 @@ namespace libtorrent void piece_picker::piece_info(int index, piece_picker::downloading_piece& st) const { #ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS -// TORRENT_PIECE_PICKER_INVARIANT_CHECK; + TORRENT_PIECE_PICKER_INVARIANT_CHECK; #endif TORRENT_ASSERT(index >= 0); @@ -153,7 +153,7 @@ namespace libtorrent std::vector::const_iterator piece = find_dl_piece(index); TORRENT_ASSERT(piece != m_downloads.end()); st = *piece; -// st.info = 0; + st.info = 0; return; } st.info = 0;