fixed rare piece picker bug

This commit is contained in:
Arvid Norberg 2009-06-28 00:32:14 +00:00
parent 44ace0b86b
commit 8454d51ba1
2 changed files with 7 additions and 3 deletions

View File

@ -72,6 +72,7 @@ release 0.14.5
* fixed bug in rename_file(). The new name would not always be saved in
the resume data
* fixed resume data compatibility with 0.13
* fixed rare piece-picker bug
release 0.14.4

View File

@ -1502,9 +1502,9 @@ namespace libtorrent
// skip pieces we can't pick, and suggested pieces
// since we've already picked those
while (!can_pick(piece, pieces)
&& std::find(suggested_pieces.begin()
|| std::find(suggested_pieces.begin()
, suggested_pieces.end(), piece)
== suggested_pieces.end())
!= suggested_pieces.end())
{
++piece;
if (piece == int(m_piece_map.size())) piece = 0;
@ -1513,11 +1513,14 @@ namespace libtorrent
}
if (done) break;
TORRENT_ASSERT(can_pick(piece, pieces));
TORRENT_ASSERT(m_piece_map[piece].downloading == false);
int start, end;
boost::tie(start, end) = expand_piece(piece, prefer_whole_pieces, pieces);
for (int k = start; k < end; ++k)
{
TORRENT_ASSERT(m_piece_map[piece].downloading == false);
TORRENT_ASSERT(m_piece_map[k].downloading == false);
TORRENT_ASSERT(m_piece_map[k].priority(this) >= 0);
int num_blocks_in_piece = blocks_in_piece(k);
if (prefer_whole_pieces == 0 && num_blocks_in_piece > num_blocks)