fix multiple bitfields issue
This commit is contained in:
@@ -563,6 +563,20 @@ namespace libtorrent
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void peer_lost(bitfield const& bits)
|
||||||
|
{
|
||||||
|
if (has_picker())
|
||||||
|
{
|
||||||
|
m_picker->dec_refcount(bits);
|
||||||
|
}
|
||||||
|
#ifdef TORRENT_DEBUG
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TORRENT_ASSERT(is_seed());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void peer_lost(int index)
|
void peer_lost(int index)
|
||||||
{
|
{
|
||||||
if (has_picker())
|
if (has_picker())
|
||||||
|
@@ -1864,6 +1864,14 @@ namespace libtorrent
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_bitfield_received)
|
||||||
|
{
|
||||||
|
// if we've already received a bitfield message
|
||||||
|
// we first need to count down all the pieces
|
||||||
|
// we believe the peer has first
|
||||||
|
t->peer_lost(bits);
|
||||||
|
}
|
||||||
|
|
||||||
m_bitfield_received = true;
|
m_bitfield_received = true;
|
||||||
|
|
||||||
// if we don't have metadata yet
|
// if we don't have metadata yet
|
||||||
@@ -1909,25 +1917,7 @@ namespace libtorrent
|
|||||||
// peer has
|
// peer has
|
||||||
// if we're a seed, we don't keep track of piece availability
|
// if we're a seed, we don't keep track of piece availability
|
||||||
bool interesting = false;
|
bool interesting = false;
|
||||||
if (!t->is_upload_only())
|
t->peer_has(bits);
|
||||||
{
|
|
||||||
t->peer_has(bits);
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)m_have_piece.size(); ++i)
|
|
||||||
{
|
|
||||||
bool have = bits[i];
|
|
||||||
if (have && !m_have_piece[i])
|
|
||||||
{
|
|
||||||
if (!t->have_piece(i) && t->picker().piece_priority(i) != 0)
|
|
||||||
interesting = true;
|
|
||||||
}
|
|
||||||
else if (!have && m_have_piece[i])
|
|
||||||
{
|
|
||||||
// this should probably not be allowed
|
|
||||||
t->peer_lost(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_have_piece = bits;
|
m_have_piece = bits;
|
||||||
m_num_pieces = num_pieces;
|
m_num_pieces = num_pieces;
|
||||||
|
Reference in New Issue
Block a user