fix integer overflow in whole_pieces_threshold logic

This commit is contained in:
arvidn 2017-09-21 05:12:04 -07:00 committed by Arvid Norberg
parent 7f4566c694
commit 5441874f10
2 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,7 @@
1.1.5 release 1.1.5 release
* fix integer overflow in whole_pieces_threshold logic
* fix uTP path MTU discovery issue on windows (DF bit was not set correctly) * fix uTP path MTU discovery issue on windows (DF bit was not set correctly)
* fix python binding for torrent_handle, to be hashable * fix python binding for torrent_handle, to be hashable
* fix IPv6 tracker support by performing the second announce in more cases * fix IPv6 tracker support by performing the second announce in more cases

View File

@ -110,12 +110,16 @@ namespace libtorrent
int prefer_contiguous_blocks = c.prefer_contiguous_blocks(); int prefer_contiguous_blocks = c.prefer_contiguous_blocks();
if (prefer_contiguous_blocks == 0 && !time_critical_mode) if (prefer_contiguous_blocks == 0
&& !time_critical_mode
&& t.settings().get_int(settings_pack::whole_pieces_threshold) > 0)
{ {
int blocks_per_piece = t.torrent_file().piece_length() / t.block_size(); int const blocks_per_piece = t.torrent_file().piece_length() / t.block_size();
prefer_contiguous_blocks = c.statistics().download_payload_rate() prefer_contiguous_blocks
* t.settings().get_int(settings_pack::whole_pieces_threshold) = (c.statistics().download_payload_rate()
> t.torrent_file().piece_length() ? blocks_per_piece : 0; > t.torrent_file().piece_length()
/ t.settings().get_int(settings_pack::whole_pieces_threshold))
? blocks_per_piece : 0;
} }
// if we prefer whole pieces, the piece picker will pick at least // if we prefer whole pieces, the piece picker will pick at least