revert a bad optimization from peer_connection's invariant check

This commit is contained in:
Arvid Norberg 2013-10-20 07:10:09 +00:00
parent 1b888eeec6
commit 5ae074994d
2 changed files with 6 additions and 12 deletions

View File

@ -5883,7 +5883,6 @@ namespace libtorrent
// num_requests[i->block].peers.push_back(&p);
}
}
piece_picker::downloading_piece last_piece;
for (std::map<piece_block, peer_count_t>::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

View File

@ -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<downloading_piece>::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;