diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 448e3fe2b..75a1d21e6 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3002,7 +3002,10 @@ namespace libtorrent t->get_suggested_pieces(ret); for (std::vector::iterator i = ret.begin() , end(ret.end()); i != end; ++i) + { + TORRENT_ASSERT(*i >= 0); send_suggest(*i); + } m_sent_suggests = true; } diff --git a/src/torrent.cpp b/src/torrent.cpp index cec142786..9c25fcf15 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6825,6 +6825,8 @@ namespace libtorrent // if we have an explicit cache, it's much more likely to // stick around, so we should suggest all pieces int num_pieces_to_suggest = int(ret.size()); + if (num_pieces_to_suggest == 0) return; + if (!settings().explicit_read_cache) num_pieces_to_suggest = (std::max)(1, int(ret.size() / 2)); ret.resize(num_pieces_to_suggest);