diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 2fe8b71fa..b4009ee54 100755 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -286,7 +286,7 @@ namespace libtorrent { if (filtered() || have()) return 0; // pieces we are currently downloading have high priority - int prio = downloading ? 1 : peer_count * 2; + int prio = downloading ? (std::min)(1, int(peer_count)) : peer_count * 2; // if the peer_count is 0 or 1, the priority cannot be higher if (prio <= 1) return prio; if (prio >= limit * 2) prio = limit * 2; diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 44f860282..af9b6977c 100755 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -1240,7 +1240,7 @@ namespace libtorrent { p.downloading = 1; if (prio > 0) move(prio, p.index); - else add(block.piece_index); + else assert(p.priority(m_sequenced_download_threshold) == 0); downloading_piece dp; dp.index = block.piece_index;