diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 683b14b20..00c96aa6f 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -522,9 +522,8 @@ namespace libtorrent // when we get a have message, this is called for that piece void peer_has(int index) { - if (m_picker.get()) + if (has_picker()) { - TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount(index); } #ifdef TORRENT_DEBUG @@ -538,9 +537,8 @@ namespace libtorrent // when we get a bitfield message, this is called for that piece void peer_has(bitfield const& bits) { - if (m_picker.get()) + if (has_picker()) { - TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount(bits); } #ifdef TORRENT_DEBUG @@ -553,9 +551,8 @@ namespace libtorrent void peer_has_all() { - if (m_picker.get()) + if (has_picker()) { - TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount_all(); } #ifdef TORRENT_DEBUG @@ -568,9 +565,8 @@ namespace libtorrent void peer_lost(int index) { - if (m_picker.get()) + if (has_picker()) { - TORRENT_ASSERT(!is_seed()); m_picker->dec_refcount(index); } #ifdef TORRENT_DEBUG diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 7317028e8..c01e22b52 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3316,7 +3316,7 @@ namespace libtorrent // if we're a seed, we don't have a piece picker // so we don't have to worry about invariants getting // out of sync with it - if (t->is_seed()) continue; + if (!t->has_picker()) continue; // this can happen if a block times out, is re-requested and // then arrives "unexpectedly" diff --git a/src/torrent.cpp b/src/torrent.cpp index 18fca1570..aa3bc8c3b 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1160,7 +1160,7 @@ namespace libtorrent int blocks_in_piece = (piece_size + block_size() - 1) / block_size(); // avoid crash trying to access the picker when there is none - if (is_seed()) return; + if (!has_picker()) return; if (picker().have_piece(piece) && (flags & torrent::overwrite_existing) == 0) @@ -1204,8 +1204,6 @@ namespace libtorrent INVARIANT_CHECK; - if (is_seed()) return; - if (m_abort) { piece_block block_finished(p.piece, p.start / block_size()); @@ -1220,6 +1218,8 @@ namespace libtorrent return; } + if (!has_picker()) return; + // if we already have this block, just ignore it. // this can happen if the same block is passed in through // add_piece() multiple times @@ -3733,7 +3733,7 @@ namespace libtorrent INVARIANT_CHECK; TORRENT_ASSERT(valid_metadata()); - if (is_seed()) + if (!has_picker()) { avail.clear(); return; @@ -5137,7 +5137,7 @@ namespace libtorrent // if this torrent is a seed, we won't have a piece picker // and there will be no half-finished pieces. - if (!is_seed()) + if (has_picker()) { const std::vector& q = m_picker->get_download_queue(); @@ -5394,7 +5394,7 @@ namespace libtorrent std::vector& blk = m_ses.m_block_info_storage; blk.clear(); - if (!valid_metadata() || is_seed()) return; + if (!valid_metadata() || !has_picker()) return; piece_picker const& p = picker(); std::vector const& q = p.get_download_queue(); @@ -6443,7 +6443,6 @@ namespace libtorrent { TORRENT_ASSERT(block_size() > 0); } -// if (is_seed()) TORRENT_ASSERT(m_picker.get() == 0); for (std::vector::const_iterator i = m_file_progress.begin()