mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
more piece picker fixes for libtorrent
This commit is contained in:
parent
5c072322e3
commit
2ffbbe1eb8
4 changed files with 17 additions and 10 deletions
|
@ -223,7 +223,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
block_downloading_alert(
|
block_downloading_alert(
|
||||||
const torrent_handle& h
|
const torrent_handle& h
|
||||||
, std::string& speedmsg
|
, char const* speedmsg
|
||||||
, int block_num
|
, int block_num
|
||||||
, int piece_num
|
, int piece_num
|
||||||
, const std::string& msg)
|
, const std::string& msg)
|
||||||
|
@ -384,3 +384,4 @@ namespace libtorrent
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,6 @@ namespace libtorrent
|
||||||
int add_blocks(std::vector<int> const& piece_list
|
int add_blocks(std::vector<int> const& piece_list
|
||||||
, const std::vector<bool>& pieces
|
, const std::vector<bool>& pieces
|
||||||
, std::vector<piece_block>& interesting_blocks
|
, std::vector<piece_block>& interesting_blocks
|
||||||
, std::vector<piece_block>& backup_blocks
|
|
||||||
, int num_blocks, int prefer_whole_pieces
|
, int num_blocks, int prefer_whole_pieces
|
||||||
, void* peer, std::vector<int> const& ignore) const;
|
, void* peer, std::vector<int> const& ignore) const;
|
||||||
|
|
||||||
|
@ -457,3 +456,4 @@ namespace libtorrent
|
||||||
|
|
||||||
#endif // TORRENT_PIECE_PICKER_HPP_INCLUDED
|
#endif // TORRENT_PIECE_PICKER_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1630,7 +1630,7 @@ namespace libtorrent
|
||||||
|
|
||||||
piece_picker::piece_state_t state;
|
piece_picker::piece_state_t state;
|
||||||
peer_speed_t speed = peer_speed();
|
peer_speed_t speed = peer_speed();
|
||||||
std::string speedmsg;
|
char const* speedmsg = 0;
|
||||||
if (speed == fast)
|
if (speed == fast)
|
||||||
{
|
{
|
||||||
speedmsg = "fast";
|
speedmsg = "fast";
|
||||||
|
@ -3003,3 +3003,4 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1149,13 +1149,13 @@ namespace libtorrent
|
||||||
if (!suggested_bucket.empty())
|
if (!suggested_bucket.empty())
|
||||||
{
|
{
|
||||||
num_blocks = add_blocks(suggested_bucket, pieces
|
num_blocks = add_blocks(suggested_bucket, pieces
|
||||||
, interesting_blocks, backup_blocks, num_blocks
|
, interesting_blocks, num_blocks
|
||||||
, prefer_whole_pieces, peer, empty_vector);
|
, prefer_whole_pieces, peer, empty_vector);
|
||||||
if (num_blocks == 0) break;
|
if (num_blocks == 0) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num_blocks = add_blocks(*bucket, pieces
|
num_blocks = add_blocks(*bucket, pieces
|
||||||
, interesting_blocks, backup_blocks, num_blocks
|
, interesting_blocks, num_blocks
|
||||||
, prefer_whole_pieces, peer, suggested_bucket);
|
, prefer_whole_pieces, peer, suggested_bucket);
|
||||||
assert(num_blocks >= 0);
|
assert(num_blocks >= 0);
|
||||||
}
|
}
|
||||||
|
@ -1193,12 +1193,12 @@ namespace libtorrent
|
||||||
if (piece == start_piece) return;
|
if (piece == start_piece) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(m_piece_map[piece].downloading == false);
|
|
||||||
|
|
||||||
int start, end;
|
int start, end;
|
||||||
boost::tie(start, end) = expand_piece(piece, prefer_whole_pieces, pieces);
|
boost::tie(start, end) = expand_piece(piece, prefer_whole_pieces, pieces);
|
||||||
for (int k = start; k < end; ++k)
|
for (int k = start; k < end; ++k)
|
||||||
{
|
{
|
||||||
|
assert(m_piece_map[piece].downloading == false);
|
||||||
|
assert(m_piece_map[k].priority(m_sequenced_download_threshold) > 0);
|
||||||
int num_blocks_in_piece = blocks_in_piece(k);
|
int num_blocks_in_piece = blocks_in_piece(k);
|
||||||
if (prefer_whole_pieces == 0 && num_blocks_in_piece > num_blocks)
|
if (prefer_whole_pieces == 0 && num_blocks_in_piece > num_blocks)
|
||||||
num_blocks_in_piece = num_blocks;
|
num_blocks_in_piece = num_blocks;
|
||||||
|
@ -1263,7 +1263,6 @@ namespace libtorrent
|
||||||
int piece_picker::add_blocks(std::vector<int> const& piece_list
|
int piece_picker::add_blocks(std::vector<int> const& piece_list
|
||||||
, std::vector<bool> const& pieces
|
, std::vector<bool> const& pieces
|
||||||
, std::vector<piece_block>& interesting_blocks
|
, std::vector<piece_block>& interesting_blocks
|
||||||
, std::vector<piece_block>& backup_blocks
|
|
||||||
, int num_blocks, int prefer_whole_pieces
|
, int num_blocks, int prefer_whole_pieces
|
||||||
, void* peer, std::vector<int> const& ignore) const
|
, void* peer, std::vector<int> const& ignore) const
|
||||||
{
|
{
|
||||||
|
@ -1286,6 +1285,7 @@ namespace libtorrent
|
||||||
int num_blocks_in_piece = blocks_in_piece(*i);
|
int num_blocks_in_piece = blocks_in_piece(*i);
|
||||||
|
|
||||||
assert(m_piece_map[*i].downloading == 0);
|
assert(m_piece_map[*i].downloading == 0);
|
||||||
|
assert(m_piece_map[*i].priority(m_sequenced_download_threshold) > 0);
|
||||||
|
|
||||||
// pick a new piece
|
// pick a new piece
|
||||||
if (prefer_whole_pieces == 0)
|
if (prefer_whole_pieces == 0)
|
||||||
|
@ -1302,6 +1302,7 @@ namespace libtorrent
|
||||||
boost::tie(start, end) = expand_piece(*i, prefer_whole_pieces, pieces);
|
boost::tie(start, end) = expand_piece(*i, prefer_whole_pieces, pieces);
|
||||||
for (int k = start; k < end; ++k)
|
for (int k = start; k < end; ++k)
|
||||||
{
|
{
|
||||||
|
assert(m_piece_map[k].priority(m_sequenced_download_threshold) > 0);
|
||||||
num_blocks_in_piece = blocks_in_piece(k);
|
num_blocks_in_piece = blocks_in_piece(k);
|
||||||
for (int j = 0; j < num_blocks_in_piece; ++j)
|
for (int j = 0; j < num_blocks_in_piece; ++j)
|
||||||
{
|
{
|
||||||
|
@ -1310,7 +1311,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num_blocks <= 0) return num_blocks < 0 ? 0 : num_blocks;
|
if (num_blocks <= 0) return 0;
|
||||||
}
|
}
|
||||||
return num_blocks;
|
return num_blocks;
|
||||||
}
|
}
|
||||||
|
@ -1338,6 +1339,8 @@ namespace libtorrent
|
||||||
// pieces that only they have downloaded/requested from
|
// pieces that only they have downloaded/requested from
|
||||||
if (on_parole && !exclusive) continue;
|
if (on_parole && !exclusive) continue;
|
||||||
|
|
||||||
|
if (prefer_whole_pieces > 0 && !exclusive_active) continue;
|
||||||
|
|
||||||
for (int j = 0; j < num_blocks_in_piece; ++j)
|
for (int j = 0; j < num_blocks_in_piece; ++j)
|
||||||
{
|
{
|
||||||
// ignore completed blocks and already requested blocks
|
// ignore completed blocks and already requested blocks
|
||||||
|
@ -1377,6 +1380,7 @@ namespace libtorrent
|
||||||
|
|
||||||
assert(num_blocks >= 0 || prefer_whole_pieces > 0);
|
assert(num_blocks >= 0 || prefer_whole_pieces > 0);
|
||||||
if (num_blocks <= 0) return 0;
|
if (num_blocks <= 0) return 0;
|
||||||
|
if (on_parole) return num_blocks;
|
||||||
|
|
||||||
interesting_blocks.insert(interesting_blocks.end()
|
interesting_blocks.insert(interesting_blocks.end()
|
||||||
, backup_blocks.begin(), backup_blocks.end());
|
, backup_blocks.begin(), backup_blocks.end());
|
||||||
|
@ -1785,3 +1789,4 @@ namespace libtorrent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue