added some more asserts around m_outstanding_bytes

This commit is contained in:
Arvid Norberg 2009-05-26 16:12:09 +00:00
parent 5874d32a34
commit 7b8ac7276c
1 changed files with 7 additions and 2 deletions

View File

@ -2616,6 +2616,7 @@ namespace libtorrent
if (t->picker().is_finished(block) || t->picker().is_downloaded(block)) if (t->picker().is_finished(block) || t->picker().is_downloaded(block))
continue; continue;
TORRENT_ASSERT(verify_piece(t->to_req(block)));
m_download_queue.push_back(block); m_download_queue.push_back(block);
m_outstanding_bytes += block_size; m_outstanding_bytes += block_size;
#if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_DEBUG #if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_DEBUG
@ -2645,6 +2646,7 @@ namespace libtorrent
break; break;
block = m_request_queue.front(); block = m_request_queue.front();
m_request_queue.erase(m_request_queue.begin()); m_request_queue.erase(m_request_queue.begin());
TORRENT_ASSERT(verify_piece(t->to_req(block)));
m_download_queue.push_back(block); m_download_queue.push_back(block);
if (m_queued_time_critical) --m_queued_time_critical; if (m_queued_time_critical) --m_queued_time_critical;
@ -4342,13 +4344,16 @@ namespace libtorrent
int outstanding_bytes = 0; int outstanding_bytes = 0;
bool in_download_queue = false; bool in_download_queue = false;
int block_size = t->block_size(); int block_size = t->block_size();
piece_block last_block(ti.num_pieces()-1, (ti.total_size() % ti.piece_length()) piece_block last_block(ti.num_pieces()-1
/ block_size); , (ti.total_size() & (ti.piece_length()-1)) / block_size);
int last_block_size = t->torrent_file().total_size() & (block_size-1); int last_block_size = t->torrent_file().total_size() & (block_size-1);
if (last_block_size == 0) last_block_size = block_size; if (last_block_size == 0) last_block_size = block_size;
for (std::vector<pending_block>::const_iterator i = m_download_queue.begin() for (std::vector<pending_block>::const_iterator i = m_download_queue.begin()
, end(m_download_queue.end()); i != end; ++i) , end(m_download_queue.end()); i != end; ++i)
{ {
TORRENT_ASSERT(i->block.piece_index <= last_block.piece_index);
TORRENT_ASSERT(i->block.piece_index < last_block.piece_index
|| i->block.block_index <= last_block.block_index);
if (p && i->block == piece_block(p->piece_index, p->block_index)) if (p && i->block == piece_block(p->piece_index, p->block_index))
{ {
in_download_queue = true; in_download_queue = true;