fix division by zero in super-seeding logic

This commit is contained in:
arvidn 2016-03-07 23:40:01 -05:00
parent 2e66708273
commit 71e3fb8941
2 changed files with 6 additions and 0 deletions

View File

@ -86,6 +86,8 @@
* almost completely changed the storage interface (for custom storage)
* added support for hashing pieces in multiple threads
* fix division by zero in super-seeding logic
1.0.9 release
* fix issue in checking outgoing interfaces (when that option is enabled)

View File

@ -5002,6 +5002,9 @@ namespace libtorrent
// seeded by any peer
TORRENT_ASSERT(m_super_seeding);
if (!need_loaded())
return -1;
// do a linear search from the first piece
int min_availability = 9999;
std::vector<int> avail_vec;
@ -5034,6 +5037,7 @@ namespace libtorrent
avail_vec.push_back(i);
}
if (avail_vec.empty()) return -1;
return avail_vec[random() % avail_vec.size()];
}