added some asserts

This commit is contained in:
Arvid Norberg 2010-04-24 19:24:27 +00:00
parent d7c30bc01b
commit d1addf876a
1 changed files with 13 additions and 0 deletions

View File

@ -2151,6 +2151,7 @@ namespace libtorrent
// update m_file_progress
TORRENT_ASSERT(m_picker);
TORRENT_ASSERT(!have_piece(index));
TORRENT_ASSERT(!m_picker->have_piece(index));
const int piece_size = m_torrent_file->piece_length();
size_type off = size_type(index) * piece_size;
@ -2195,6 +2196,17 @@ namespace libtorrent
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
#ifdef TORRENT_DEBUG
// make sure all blocks were successfully written before we
// declare the piece has "we have".
piece_picker::downloading_piece dp;
m_picker->piece_info(index, dp);
int blocks_in_piece = m_picker->blocks_in_piece(index);
TORRENT_ASSERT(dp.finished == blocks_in_piece);
TORRENT_ASSERT(dp.writing == 0);
TORRENT_ASSERT(dp.requested == 0);
TORRENT_ASSERT(dp.index == index);
#endif
if (m_ses.m_alerts.should_post<piece_finished_alert>())
{
@ -5998,6 +6010,7 @@ namespace libtorrent
TORRENT_ASSERT(piece_index >= 0);
TORRENT_ASSERT(piece_index < m_torrent_file->num_pieces());
TORRENT_ASSERT(piece_index < (int)m_picker->num_pieces());
TORRENT_ASSERT(!m_picker || !m_picker->have_piece(piece_index));
#ifdef TORRENT_DEBUG
if (m_picker)
{