since the web seed downloader now calls incoming_piece with correct block sizes, incoming piece can be reverted to not allow incorrect block sizes
This commit is contained in:
parent
1b46fb9e1b
commit
755d9f5967
|
@ -991,10 +991,10 @@ namespace libtorrent
|
||||||
|
|
||||||
std::vector<piece_block> finished_blocks;
|
std::vector<piece_block> finished_blocks;
|
||||||
piece_block block_finished(p.piece, p.start / t->block_size());
|
piece_block block_finished(p.piece, p.start / t->block_size());
|
||||||
bool redundant = true;
|
assert(p.start % t->block_size() == 0);
|
||||||
for (;block_finished.block_index * t->block_size() < p.start + p.length;
|
assert(p.length == t->block_size()
|
||||||
++block_finished.block_index)
|
|| p.length == t->torrent_file().total_size() % t->block_size());
|
||||||
{
|
|
||||||
std::deque<piece_block>::iterator b
|
std::deque<piece_block>::iterator b
|
||||||
= std::find(
|
= std::find(
|
||||||
m_download_queue.begin()
|
m_download_queue.begin()
|
||||||
|
@ -1010,11 +1010,11 @@ namespace libtorrent
|
||||||
for (i = m_download_queue.begin();
|
for (i = m_download_queue.begin();
|
||||||
i != b; ++i)
|
i != b; ++i)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||||
<< " *** SKIPPED_PIECE [ piece: " << i->piece_index << " | "
|
<< " *** SKIPPED_PIECE [ piece: " << i->piece_index << " | "
|
||||||
"b: " << i->block_index << " ] ***\n";
|
"b: " << i->block_index << " ] ***\n";
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
// TODO: send cancel?
|
// TODO: send cancel?
|
||||||
|
@ -1057,10 +1057,10 @@ namespace libtorrent
|
||||||
, m_peer_id
|
, m_peer_id
|
||||||
, "got a block that was not requested"));
|
, "got a block that was not requested"));
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
(*m_logger) << " *** The block we just got was not in the "
|
(*m_logger) << " *** The block we just got was not in the "
|
||||||
"request queue ***\n";
|
"request queue ***\n";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,21 +1068,16 @@ namespace libtorrent
|
||||||
if (picker.is_finished(block_finished))
|
if (picker.is_finished(block_finished))
|
||||||
{
|
{
|
||||||
t->received_redundant_data(t->block_size());
|
t->received_redundant_data(t->block_size());
|
||||||
|
send_block_requests();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
fs.write(data, p.piece, p.start, p.length);
|
||||||
redundant = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
picker.mark_as_finished(block_finished, m_remote);
|
picker.mark_as_finished(block_finished, m_remote);
|
||||||
t->get_policy().block_finished(*this, block_finished);
|
t->get_policy().block_finished(*this, block_finished);
|
||||||
|
|
||||||
send_block_requests();
|
send_block_requests();
|
||||||
}
|
|
||||||
|
|
||||||
if (redundant) return;
|
|
||||||
|
|
||||||
fs.write(data, p.piece, p.start, p.length);
|
|
||||||
|
|
||||||
bool was_seed = t->is_seed();
|
bool was_seed = t->is_seed();
|
||||||
bool was_finished = picker.num_filtered() + t->num_pieces()
|
bool was_finished = picker.num_filtered() + t->num_pieces()
|
||||||
|
|
|
@ -395,7 +395,7 @@ namespace libtorrent
|
||||||
int copy_size = std::min(front_request.length - int(m_piece.size())
|
int copy_size = std::min(front_request.length - int(m_piece.size())
|
||||||
, http_body.left());
|
, http_body.left());
|
||||||
std::copy(http_body.begin, http_body.begin + copy_size, std::back_inserter(m_piece));
|
std::copy(http_body.begin, http_body.begin + copy_size, std::back_inserter(m_piece));
|
||||||
assert(int(m_piece.size() <= front_request.length));
|
assert(int(m_piece.size()) <= front_request.length);
|
||||||
http_body.begin += copy_size;
|
http_body.begin += copy_size;
|
||||||
int piece_size = int(m_piece.size());
|
int piece_size = int(m_piece.size());
|
||||||
if (piece_size < front_request.length)
|
if (piece_size < front_request.length)
|
||||||
|
|
Loading…
Reference in New Issue