forked from premiere/premiere-libtorrent
added more asserts related to the invariance between the peer connections' request queue and the piece picker
This commit is contained in:
parent
0bad3bcc48
commit
400a2fe82a
|
@ -601,19 +601,20 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!t->is_seed())
|
if (!t->is_seed())
|
||||||
{
|
{
|
||||||
|
piece_picker& p = t->picker();
|
||||||
// remove all pieces from this peers download queue and
|
// remove all pieces from this peers download queue and
|
||||||
// remove the 'downloading' flag from piece_picker.
|
// remove the 'downloading' flag from piece_picker.
|
||||||
for (std::deque<piece_block>::iterator i = m_download_queue.begin();
|
for (std::deque<piece_block>::iterator i = m_download_queue.begin();
|
||||||
i != m_download_queue.end(); ++i)
|
i != m_download_queue.end(); ++i)
|
||||||
{
|
{
|
||||||
t->picker().abort_download(*i);
|
p.abort_download(*i);
|
||||||
}
|
}
|
||||||
for (std::deque<piece_block>::const_iterator i = m_request_queue.begin()
|
for (std::deque<piece_block>::const_iterator i = m_request_queue.begin()
|
||||||
, end(m_request_queue.end()); i != end; ++i)
|
, end(m_request_queue.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
// since this piece was skipped, clear it and allow it to
|
// since this piece was skipped, clear it and allow it to
|
||||||
// be requested from other peers
|
// be requested from other peers
|
||||||
t->picker().abort_download(*i);
|
p.abort_download(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +622,22 @@ namespace libtorrent
|
||||||
m_request_queue.clear();
|
m_request_queue.clear();
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// t->picker().integrity_check(m_torrent);
|
if (!t->is_seed())
|
||||||
|
{
|
||||||
|
piece_picker& p = t->picker();
|
||||||
|
const std::vector<piece_picker::downloading_piece>& dlq = p.get_download_queue();
|
||||||
|
const int blocks_per_piece = static_cast<int>(
|
||||||
|
t->torrent_file().piece_length() / t->block_size());
|
||||||
|
|
||||||
|
for (std::vector<piece_picker::downloading_piece>::const_iterator i =
|
||||||
|
dlq.begin(); i != dlq.end(); ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < blocks_per_piece; ++j)
|
||||||
|
{
|
||||||
|
assert(i->info[j].peer != m_remote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -983,7 +999,11 @@ namespace libtorrent
|
||||||
|
|
||||||
// if we're already seeding, don't bother,
|
// if we're already seeding, don't bother,
|
||||||
// just ignore it
|
// just ignore it
|
||||||
if (t->is_seed()) return;
|
if (t->is_seed())
|
||||||
|
{
|
||||||
|
t->received_redundant_data(p.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
piece_picker& picker = t->picker();
|
piece_picker& picker = t->picker();
|
||||||
piece_manager& fs = t->filesystem();
|
piece_manager& fs = t->filesystem();
|
||||||
|
@ -1498,6 +1518,19 @@ namespace libtorrent
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!t->is_seed())
|
if (!t->is_seed())
|
||||||
{
|
{
|
||||||
|
piece_picker& p = t->picker();
|
||||||
|
const std::vector<piece_picker::downloading_piece>& dlq = p.get_download_queue();
|
||||||
|
const int blocks_per_piece = static_cast<int>(
|
||||||
|
t->torrent_file().piece_length() / t->block_size());
|
||||||
|
|
||||||
|
for (std::vector<piece_picker::downloading_piece>::const_iterator i =
|
||||||
|
dlq.begin(); i != dlq.end(); ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < blocks_per_piece; ++j)
|
||||||
|
{
|
||||||
|
assert(i->info[j].peer != m_remote);
|
||||||
|
}
|
||||||
|
}
|
||||||
assert(m_download_queue.empty());
|
assert(m_download_queue.empty());
|
||||||
assert(m_request_queue.empty());
|
assert(m_request_queue.empty());
|
||||||
}
|
}
|
||||||
|
@ -1625,6 +1658,26 @@ namespace libtorrent
|
||||||
m_request_queue.pop_back();
|
m_request_queue.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (!t->is_seed())
|
||||||
|
{
|
||||||
|
piece_picker& p = t->picker();
|
||||||
|
const std::vector<piece_picker::downloading_piece>& dlq = p.get_download_queue();
|
||||||
|
const int blocks_per_piece = static_cast<int>(
|
||||||
|
t->torrent_file().piece_length() / t->block_size());
|
||||||
|
|
||||||
|
for (std::vector<piece_picker::downloading_piece>::const_iterator i =
|
||||||
|
dlq.begin(); i != dlq.end(); ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < blocks_per_piece; ++j)
|
||||||
|
{
|
||||||
|
assert(i->info[j].peer != m_remote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// TODO: If we have a limited number of upload
|
// TODO: If we have a limited number of upload
|
||||||
// slots, choke this peer
|
// slots, choke this peer
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue