forked from premiere/premiere-libtorrent
add asserts to try to catch crash in peer_connection::received_valid_data
This commit is contained in:
parent
8b459a27bd
commit
f7b5c10b2b
|
@ -1261,6 +1261,7 @@ namespace libtorrent
|
|||
bool m_in_constructor:1;
|
||||
bool m_disconnect_started:1;
|
||||
bool m_initialized:1;
|
||||
int m_in_use;
|
||||
int m_received_in_piece;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -311,7 +311,7 @@ namespace libtorrent
|
|||
// we have been connected via uTP at least once
|
||||
bool confirmed_supports_utp:1;
|
||||
bool supports_holepunch:1;
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
bool in_use:1;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -198,6 +198,7 @@ namespace libtorrent
|
|||
, m_in_constructor(true)
|
||||
, m_disconnect_started(false)
|
||||
, m_initialized(false)
|
||||
, m_in_use(1337)
|
||||
, m_received_in_piece(0)
|
||||
#endif
|
||||
{
|
||||
|
@ -349,6 +350,7 @@ namespace libtorrent
|
|||
, m_in_constructor(true)
|
||||
, m_disconnect_started(false)
|
||||
, m_initialized(false)
|
||||
, m_in_use(1337)
|
||||
, m_received_in_piece(0)
|
||||
#endif
|
||||
{
|
||||
|
@ -915,6 +917,10 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_disconnecting);
|
||||
TORRENT_ASSERT(m_disconnect_started);
|
||||
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
m_in_use = 0;
|
||||
#endif
|
||||
|
||||
// defensive
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
|
@ -5650,6 +5656,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::check_invariant() const
|
||||
{
|
||||
TORRENT_ASSERT(m_in_use == 1337);
|
||||
TORRENT_ASSERT(m_queued_time_critical <= int(m_request_queue.size()));
|
||||
|
||||
TORRENT_ASSERT(bool(m_disk_recv_buffer) == (m_disk_recv_buffer_size > 0));
|
||||
|
|
|
@ -423,7 +423,7 @@ namespace libtorrent
|
|||
if (m_round_robin > i - m_peers.begin()) --m_round_robin;
|
||||
if (m_round_robin >= int(m_peers.size())) m_round_robin = 0;
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
TORRENT_ASSERT((*i)->in_use);
|
||||
(*i)->in_use = false;
|
||||
#endif
|
||||
|
@ -933,7 +933,7 @@ namespace libtorrent
|
|||
#endif
|
||||
new (p) ipv4_peer(c.remote(), false, 0);
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
p->in_use = true;
|
||||
#endif
|
||||
|
||||
|
@ -1214,13 +1214,13 @@ namespace libtorrent
|
|||
m_torrent->session().m_i2p_peer_pool.set_next_size(500);
|
||||
new (p) i2p_peer(destination, true, src);
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
p->in_use = true;
|
||||
#endif
|
||||
|
||||
if (!insert_peer(p, iter, flags))
|
||||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
p->in_use = false;
|
||||
#endif
|
||||
|
||||
|
@ -1339,13 +1339,13 @@ namespace libtorrent
|
|||
#endif
|
||||
new (p) ipv4_peer(remote, true, src);
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
p->in_use = true;
|
||||
#endif
|
||||
|
||||
if (!insert_peer(p, iter, flags))
|
||||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
p->in_use = false;
|
||||
#endif
|
||||
#if TORRENT_USE_IPV6
|
||||
|
@ -1677,7 +1677,7 @@ namespace libtorrent
|
|||
, supports_utp(true) // assume peers support utp
|
||||
, confirmed_supports_utp(false)
|
||||
, supports_holepunch(false)
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
|
||||
, in_use(false)
|
||||
#endif
|
||||
{
|
||||
|
|
|
@ -3140,12 +3140,17 @@ namespace libtorrent
|
|||
{
|
||||
policy::peer* p = static_cast<policy::peer*>(*i);
|
||||
if (p == 0) continue;
|
||||
TORRENT_ASSERT(p->in_use);
|
||||
p->on_parole = false;
|
||||
int trust_points = p->trust_points;
|
||||
++trust_points;
|
||||
if (trust_points > 8) trust_points = 8;
|
||||
p->trust_points = trust_points;
|
||||
if (p->connection) p->connection->received_valid_data(index);
|
||||
if (p->connection)
|
||||
{
|
||||
TORRENT_ASSERT(p->connection->m_in_use == 1337);
|
||||
p->connection->received_valid_data(index);
|
||||
}
|
||||
}
|
||||
|
||||
if (settings().max_sparse_regions > 0
|
||||
|
|
Loading…
Reference in New Issue