release assert fixes

This commit is contained in:
Arvid Norberg
2011-05-08 23:52:06 +00:00
parent a73960aa5a
commit e946ba654f
3 changed files with 20 additions and 18 deletions

View File

@@ -112,7 +112,7 @@ namespace libtorrent
, m_sync_bytes_read(0) , m_sync_bytes_read(0)
, m_enc_send_buffer(0, 0) , m_enc_send_buffer(0, 0)
#endif #endif
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
, m_sent_bitfield(false) , m_sent_bitfield(false)
, m_in_constructor(true) , m_in_constructor(true)
, m_sent_handshake(false) , m_sent_handshake(false)
@@ -150,7 +150,7 @@ namespace libtorrent
, m_sync_bytes_read(0) , m_sync_bytes_read(0)
, m_enc_send_buffer(0, 0) , m_enc_send_buffer(0, 0)
#endif #endif
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
, m_sent_bitfield(false) , m_sent_bitfield(false)
, m_in_constructor(true) , m_in_constructor(true)
, m_sent_handshake(false) , m_sent_handshake(false)
@@ -289,7 +289,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
@@ -303,7 +303,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
@@ -790,7 +790,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(!m_sent_handshake); TORRENT_ASSERT(!m_sent_handshake);
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_sent_handshake = true; m_sent_handshake = true;
#endif #endif
@@ -2002,7 +2002,7 @@ namespace libtorrent
// if we are super seeding, pretend to not have any piece // if we are super seeding, pretend to not have any piece
// and don't send a bitfield // and don't send a bitfield
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
@@ -2029,7 +2029,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
peer_log(" *** NOT SENDING BITFIELD"); peer_log(" *** NOT SENDING BITFIELD");
#endif #endif
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
return; return;
@@ -2106,7 +2106,7 @@ namespace libtorrent
} }
peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str()); peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str());
#endif #endif
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
@@ -3095,6 +3095,7 @@ namespace libtorrent
if (!is_local()) write_handshake(); if (!is_local()) write_handshake();
// if (t->valid_metadata()) // if (t->valid_metadata())
// write_bitfield(); // write_bitfield();
TORRENT_ASSERT(m_sent_handshake);
if (is_disconnecting()) return; if (is_disconnecting()) return;
@@ -3107,6 +3108,7 @@ namespace libtorrent
// fall through // fall through
if (m_state == read_peer_id) if (m_state == read_peer_id)
{ {
TORRENT_ASSERT(m_sent_handshake);
m_statistics.received_bytes(0, bytes_transferred); m_statistics.received_bytes(0, bytes_transferred);
bytes_transferred = 0; bytes_transferred = 0;
if (!t) if (!t)

View File

@@ -161,7 +161,7 @@ namespace libtorrent
, m_sent_suggests(false) , m_sent_suggests(false)
, m_holepunch_mode(false) , m_holepunch_mode(false)
, m_ignore_stats(false) , m_ignore_stats(false)
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
, m_in_constructor(true) , m_in_constructor(true)
, m_disconnect_started(false) , m_disconnect_started(false)
, m_initialized(false) , m_initialized(false)
@@ -304,7 +304,7 @@ namespace libtorrent
, m_sent_suggests(false) , m_sent_suggests(false)
, m_holepunch_mode(false) , m_holepunch_mode(false)
, m_ignore_stats(false) , m_ignore_stats(false)
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
, m_in_constructor(true) , m_in_constructor(true)
, m_disconnect_started(false) , m_disconnect_started(false)
, m_initialized(false) , m_initialized(false)
@@ -812,7 +812,7 @@ namespace libtorrent
m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all); m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all);
if (m_have_all) m_num_pieces = t->torrent_file().num_pieces(); if (m_have_all) m_num_pieces = t->torrent_file().num_pieces();
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_initialized = true; m_initialized = true;
#endif #endif
// now that we have a piece_picker, // now that we have a piece_picker,
@@ -2046,7 +2046,7 @@ namespace libtorrent
TORRENT_ASSERT(m_outstanding_bytes >= bytes); TORRENT_ASSERT(m_outstanding_bytes >= bytes);
m_outstanding_bytes -= bytes; m_outstanding_bytes -= bytes;
if (m_outstanding_bytes < 0) m_outstanding_bytes = 0; if (m_outstanding_bytes < 0) m_outstanding_bytes = 0;
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
boost::shared_ptr<torrent> t = associated_torrent().lock(); boost::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(m_received_in_piece + bytes <= t->block_size()); TORRENT_ASSERT(m_received_in_piece + bytes <= t->block_size());
m_received_in_piece += bytes; m_received_in_piece += bytes;
@@ -2206,7 +2206,7 @@ namespace libtorrent
{ {
if ((*i)->on_piece(p, data)) if ((*i)->on_piece(p, data))
{ {
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
TORRENT_ASSERT(m_received_in_piece == p.length); TORRENT_ASSERT(m_received_in_piece == p.length);
m_received_in_piece = 0; m_received_in_piece = 0;
#endif #endif
@@ -2245,7 +2245,7 @@ namespace libtorrent
// just ignore it // just ignore it
if (t->is_seed()) if (t->is_seed())
{ {
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
TORRENT_ASSERT(m_received_in_piece == p.length); TORRENT_ASSERT(m_received_in_piece == p.length);
m_received_in_piece = 0; m_received_in_piece = 0;
#endif #endif
@@ -2279,7 +2279,7 @@ namespace libtorrent
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
peer_log("*** The block we just got was not in the request queue ***"); peer_log("*** The block we just got was not in the request queue ***");
#endif #endif
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
TORRENT_ASSERT_VAL(m_received_in_piece == p.length, m_received_in_piece); TORRENT_ASSERT_VAL(m_received_in_piece == p.length, m_received_in_piece);
m_received_in_piece = 0; m_received_in_piece = 0;
#endif #endif
@@ -2340,7 +2340,7 @@ namespace libtorrent
b = m_download_queue.begin() + block_index; b = m_download_queue.begin() + block_index;
TORRENT_ASSERT(*b == pending_b); TORRENT_ASSERT(*b == pending_b);
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
TORRENT_ASSERT_VAL(m_received_in_piece == p.length, m_received_in_piece); TORRENT_ASSERT_VAL(m_received_in_piece == p.length, m_received_in_piece);
m_received_in_piece = 0; m_received_in_piece = 0;
#endif #endif
@@ -3309,7 +3309,7 @@ namespace libtorrent
// 2 protocol error (client sent something invalid) // 2 protocol error (client sent something invalid)
void peer_connection::disconnect(error_code const& ec, int error) void peer_connection::disconnect(error_code const& ec, int error)
{ {
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_disconnect_started = true; m_disconnect_started = true;
#endif #endif

View File

@@ -2314,7 +2314,7 @@ namespace aux {
boost::intrusive_ptr<peer_connection> c( boost::intrusive_ptr<peer_connection> c(
new bt_peer_connection(*this, s, endp, 0)); new bt_peer_connection(*this, s, endp, 0));
#ifdef TORRENT_DEBUG #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
c->m_in_constructor = false; c->m_in_constructor = false;
#endif #endif