fixed resume data problem caused by recent piece_picker optimization

This commit is contained in:
Arvid Norberg 2007-05-09 03:18:53 +00:00
parent 6dcca9250b
commit 4371dbe02c
2 changed files with 7 additions and 4 deletions

View File

@ -109,6 +109,7 @@ namespace libtorrent
std::vector<int> piece_map;
std::vector<piece_picker::downloading_piece> unfinished_pieces;
std::vector<piece_picker::block_info> block_info;
std::vector<tcp::endpoint> peers;
entry resume_data;

View File

@ -1875,13 +1875,15 @@ namespace libtorrent { namespace detail
// the unfinished pieces
entry::list_type& unfinished = rd["unfinished"].list();
tmp_unfinished.reserve(unfinished.size());
int unfinished_size = int(unfinished.size());
block_info.resize(num_blocks_per_piece * unfinished_size);
tmp_unfinished.reserve(unfinished_size);
int index = 0;
for (entry::list_type::iterator i = unfinished.begin();
i != unfinished.end(); ++i)
i != unfinished.end(); ++i, ++index)
{
piece_picker::downloading_piece p;
p.info = &block_info[index * num_blocks_per_piece];
p.index = (int)(*i)["piece"].integer();
if (p.index < 0 || p.index >= info.num_pieces())
{