fix invariant check

This commit is contained in:
Arvid Norberg 2012-09-11 05:27:14 +00:00
parent f8f03431bb
commit 0ec16827ff
2 changed files with 15 additions and 1 deletions

View File

@ -215,6 +215,15 @@ namespace libtorrent
return m_piece_map[index].index == piece_pos::we_have_index;
}
bool is_downloading(int index) const
{
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < int(m_piece_map.size()));
piece_pos const& p = m_piece_map[index];
return p.downloading;
}
// sets the priority of a piece.
// returns true if the priority was changed from 0 to non-0
// or vice versa

View File

@ -6485,7 +6485,12 @@ namespace libtorrent
piece_block b = i->first;
int count = i->second;
int picker_count = m_picker->num_peers(b);
if (!m_picker->is_downloaded(b))
// if we're no longer downloading the piece
// (for instance, it may be fully downloaded and waiting
// for the hash check to return), the piece picker always
// returns 0 requests, regardless of how many peers may still
// have the block in their queue
if (!m_picker->is_downloaded(b) && m_picker->is_downloading(b.piece_index))
TORRENT_ASSERT(picker_count == count);
}
TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered());