fixed bug in peer_connection::incoming_piece() in case blocks were skipped. Fixed warnings.

This commit is contained in:
Arvid Norberg 2008-09-25 20:12:53 +00:00
parent 00415608f6
commit a3751cfcbe
2 changed files with 8 additions and 2 deletions

View File

@ -1693,6 +1693,9 @@ namespace libtorrent
send_block_requests(); send_block_requests();
return; return;
} }
#ifndef NDEBUG
pending_block pending_b = *b;
#endif
int block_index = b - m_download_queue.begin() - 1; int block_index = b - m_download_queue.begin() - 1;
for (int i = 0; i < block_index; ++i) for (int i = 0; i < block_index; ++i)
@ -1721,6 +1724,9 @@ namespace libtorrent
--block_index; --block_index;
} }
} }
TORRENT_ASSERT(int(m_download_queue.size()) > block_index + 1);
b = m_download_queue.begin() + (block_index + 1);
TORRENT_ASSERT(b->block == pending_b.block);
// if the block we got is already finished, then ignore it // if the block we got is already finished, then ignore it
if (picker.is_downloaded(block_finished)) if (picker.is_downloaded(block_finished))
@ -3856,7 +3862,7 @@ namespace libtorrent
} }
if (t->ready_for_connections() && m_initialized) if (t->ready_for_connections() && m_initialized)
TORRENT_ASSERT(t->torrent_file().num_pieces() == m_have_piece.size()); TORRENT_ASSERT(t->torrent_file().num_pieces() == int(m_have_piece.size()));
if (m_ses.settings().close_redundant_connections) if (m_ses.settings().close_redundant_connections)
{ {

View File

@ -2508,7 +2508,7 @@ namespace aux {
++total_downloaders; ++total_downloaders;
unique.insert(i->second->queue_position()); unique.insert(i->second->queue_position());
} }
TORRENT_ASSERT(unique.size() == int(total_downloaders)); TORRENT_ASSERT(int(unique.size()) == total_downloaders);
TORRENT_ASSERT(m_max_connections > 0); TORRENT_ASSERT(m_max_connections > 0);
TORRENT_ASSERT(m_max_uploads > 0); TORRENT_ASSERT(m_max_uploads > 0);