is_seed() is not a good indicator of whether or not we have a piece picker. use has_picker() instead
This commit is contained in:
parent
4ae349f61f
commit
2fc7f2191f
|
@ -522,9 +522,8 @@ namespace libtorrent
|
||||||
// when we get a have message, this is called for that piece
|
// when we get a have message, this is called for that piece
|
||||||
void peer_has(int index)
|
void peer_has(int index)
|
||||||
{
|
{
|
||||||
if (m_picker.get())
|
if (has_picker())
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(!is_seed());
|
|
||||||
m_picker->inc_refcount(index);
|
m_picker->inc_refcount(index);
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
|
@ -538,9 +537,8 @@ namespace libtorrent
|
||||||
// when we get a bitfield message, this is called for that piece
|
// when we get a bitfield message, this is called for that piece
|
||||||
void peer_has(bitfield const& bits)
|
void peer_has(bitfield const& bits)
|
||||||
{
|
{
|
||||||
if (m_picker.get())
|
if (has_picker())
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(!is_seed());
|
|
||||||
m_picker->inc_refcount(bits);
|
m_picker->inc_refcount(bits);
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
|
@ -553,9 +551,8 @@ namespace libtorrent
|
||||||
|
|
||||||
void peer_has_all()
|
void peer_has_all()
|
||||||
{
|
{
|
||||||
if (m_picker.get())
|
if (has_picker())
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(!is_seed());
|
|
||||||
m_picker->inc_refcount_all();
|
m_picker->inc_refcount_all();
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
|
@ -568,9 +565,8 @@ namespace libtorrent
|
||||||
|
|
||||||
void peer_lost(int index)
|
void peer_lost(int index)
|
||||||
{
|
{
|
||||||
if (m_picker.get())
|
if (has_picker())
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(!is_seed());
|
|
||||||
m_picker->dec_refcount(index);
|
m_picker->dec_refcount(index);
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
|
|
|
@ -3316,7 +3316,7 @@ namespace libtorrent
|
||||||
// if we're a seed, we don't have a piece picker
|
// if we're a seed, we don't have a piece picker
|
||||||
// so we don't have to worry about invariants getting
|
// so we don't have to worry about invariants getting
|
||||||
// out of sync with it
|
// 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
|
// this can happen if a block times out, is re-requested and
|
||||||
// then arrives "unexpectedly"
|
// then arrives "unexpectedly"
|
||||||
|
|
|
@ -1160,7 +1160,7 @@ namespace libtorrent
|
||||||
int blocks_in_piece = (piece_size + block_size() - 1) / block_size();
|
int blocks_in_piece = (piece_size + block_size() - 1) / block_size();
|
||||||
|
|
||||||
// avoid crash trying to access the picker when there is none
|
// avoid crash trying to access the picker when there is none
|
||||||
if (is_seed()) return;
|
if (!has_picker()) return;
|
||||||
|
|
||||||
if (picker().have_piece(piece)
|
if (picker().have_piece(piece)
|
||||||
&& (flags & torrent::overwrite_existing) == 0)
|
&& (flags & torrent::overwrite_existing) == 0)
|
||||||
|
@ -1204,8 +1204,6 @@ namespace libtorrent
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (is_seed()) return;
|
|
||||||
|
|
||||||
if (m_abort)
|
if (m_abort)
|
||||||
{
|
{
|
||||||
piece_block block_finished(p.piece, p.start / block_size());
|
piece_block block_finished(p.piece, p.start / block_size());
|
||||||
|
@ -1220,6 +1218,8 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!has_picker()) return;
|
||||||
|
|
||||||
// if we already have this block, just ignore it.
|
// if we already have this block, just ignore it.
|
||||||
// this can happen if the same block is passed in through
|
// this can happen if the same block is passed in through
|
||||||
// add_piece() multiple times
|
// add_piece() multiple times
|
||||||
|
@ -3733,7 +3733,7 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
TORRENT_ASSERT(valid_metadata());
|
TORRENT_ASSERT(valid_metadata());
|
||||||
if (is_seed())
|
if (!has_picker())
|
||||||
{
|
{
|
||||||
avail.clear();
|
avail.clear();
|
||||||
return;
|
return;
|
||||||
|
@ -5137,7 +5137,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// if this torrent is a seed, we won't have a piece picker
|
// if this torrent is a seed, we won't have a piece picker
|
||||||
// and there will be no half-finished pieces.
|
// and there will be no half-finished pieces.
|
||||||
if (!is_seed())
|
if (has_picker())
|
||||||
{
|
{
|
||||||
const std::vector<piece_picker::downloading_piece>& q
|
const std::vector<piece_picker::downloading_piece>& q
|
||||||
= m_picker->get_download_queue();
|
= m_picker->get_download_queue();
|
||||||
|
@ -5394,7 +5394,7 @@ namespace libtorrent
|
||||||
std::vector<block_info>& blk = m_ses.m_block_info_storage;
|
std::vector<block_info>& blk = m_ses.m_block_info_storage;
|
||||||
blk.clear();
|
blk.clear();
|
||||||
|
|
||||||
if (!valid_metadata() || is_seed()) return;
|
if (!valid_metadata() || !has_picker()) return;
|
||||||
piece_picker const& p = picker();
|
piece_picker const& p = picker();
|
||||||
std::vector<piece_picker::downloading_piece> const& q
|
std::vector<piece_picker::downloading_piece> const& q
|
||||||
= p.get_download_queue();
|
= p.get_download_queue();
|
||||||
|
@ -6443,7 +6443,6 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(block_size() > 0);
|
TORRENT_ASSERT(block_size() > 0);
|
||||||
}
|
}
|
||||||
// if (is_seed()) TORRENT_ASSERT(m_picker.get() == 0);
|
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<size_type>::const_iterator i = m_file_progress.begin()
|
for (std::vector<size_type>::const_iterator i = m_file_progress.begin()
|
||||||
|
|
Loading…
Reference in New Issue