fixed sequenced download bug

This commit is contained in:
Arvid Norberg 2006-10-02 08:58:28 +00:00
parent 57471d4b37
commit f029f5d6b2
2 changed files with 16 additions and 9 deletions

View File

@ -1,3 +1,5 @@
* fixed bug occuring when increasing the sequenced download threshold
with max availability lower than previous threshold.
* fixed an integer overflow bug occuring when built with gcc 4.1.x
* fixed crasing bug when closing while checking a torrent
* fixed bug causing a crash with a torrent with piece length 0

View File

@ -166,20 +166,25 @@ namespace libtorrent
if (old_limit < sequenced_download_threshold)
{
assert(int(m_piece_info.size()) > old_limit);
info_t& in = m_piece_info[old_limit];
std::random_shuffle(in.begin(), in.end());
int c = 0;
for (info_t::iterator i = in.begin()
, end(in.end()); i != end; ++i)
// the threshold was incremented, in case
// the previous max availability was reached
// we need to shuffle that bucket, if not, we
// don't have to do anything
if (int(m_piece_info.size()) > old_limit)
{
m_piece_map[*i].index = c++;
assert(m_piece_map[*i].priority(old_limit) == old_limit);
info_t& in = m_piece_info[old_limit];
std::random_shuffle(in.begin(), in.end());
int c = 0;
for (info_t::iterator i = in.begin()
, end(in.end()); i != end; ++i)
{
m_piece_map[*i].index = c++;
assert(m_piece_map[*i].priority(old_limit) == old_limit);
}
}
}
else if (int(m_piece_info.size()) > sequenced_download_threshold)
{
assert(int(m_piece_info.size()) > sequenced_download_threshold);
info_t& in = m_piece_info[sequenced_download_threshold];
std::sort(in.begin(), in.end());
int c = 0;