back-port heavy weight refcount invariant checking from libtorrent_aio (disabled by default). and also backport piece-picker refcounting bug fix

This commit is contained in:
Arvid Norberg
2013-01-06 04:02:29 +00:00
parent c29b019291
commit e45124fc22
6 changed files with 134 additions and 69 deletions

View File

@@ -697,7 +697,7 @@ namespace libtorrent
t->get_policy().set_seed(m_peer_info, true);
m_upload_only = true;
t->peer_has_all();
t->peer_has_all(this);
if (t->is_upload_only()) send_not_interested();
else t->get_policy().peer_is_interesting(*this);
return;
@@ -706,7 +706,7 @@ namespace libtorrent
// if we're a seed, we don't keep track of piece availability
if (!t->is_seed())
{
t->peer_has(m_have_piece);
t->peer_has(m_have_piece, this);
bool interesting = false;
for (int i = 0; i < int(m_have_piece.size()); ++i)
{
@@ -1617,7 +1617,7 @@ namespace libtorrent
// we won't have a piece picker)
if (!t->valid_metadata()) return;
t->peer_has(index);
t->peer_has(index, this);
// this will disregard all have messages we get within
// the first two seconds. Since some clients implements
@@ -1722,7 +1722,7 @@ namespace libtorrent
// we won't have a piece picker)
if (!t->valid_metadata()) return;
t->peer_lost(index);
t->peer_lost(index, this);
if (was_seed)
t->get_policy().set_seed(m_peer_info, false);
@@ -1771,7 +1771,7 @@ namespace libtorrent
// 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(m_have_piece);
t->peer_lost(m_have_piece, this);
}
m_bitfield_received = true;
@@ -1806,7 +1806,7 @@ namespace libtorrent
m_have_piece.set_all();
m_num_pieces = num_pieces;
t->peer_has_all();
t->peer_has_all(this);
if (!t->is_upload_only())
t->get_policy().peer_is_interesting(*this);
@@ -1819,7 +1819,7 @@ namespace libtorrent
// peer has
// if we're a seed, we don't keep track of piece availability
bool interesting = false;
t->peer_has(bits);
t->peer_has(bits, this);
m_have_piece = bits;
m_num_pieces = num_pieces;
@@ -2625,7 +2625,7 @@ namespace libtorrent
if (is_disconnecting()) return;
if (m_bitfield_received)
t->peer_lost(m_have_piece);
t->peer_lost(m_have_piece, this);
m_have_all = true;
@@ -2658,7 +2658,7 @@ namespace libtorrent
m_have_piece.set_all();
m_num_pieces = m_have_piece.size();
t->peer_has_all();
t->peer_has_all(this);
// if we're finished, we're not interested
if (t->is_upload_only()) send_not_interested();
@@ -2692,7 +2692,7 @@ namespace libtorrent
if (is_disconnecting()) return;
if (m_bitfield_received)
t->peer_lost(m_have_piece);
t->peer_lost(m_have_piece, this);
t->get_policy().set_seed(m_peer_info, false);
m_bitfield_received = true;
@@ -5711,7 +5711,7 @@ namespace libtorrent
TORRENT_ASSERT(m_disconnect_started);
}
if (!m_disconnect_started && m_initialized)
if (!m_disconnect_started && m_initialized && m_ses.settings().close_redundant_connections)
{
// none of this matters if we're disconnecting anyway
if (t->is_upload_only())