diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index b431617c3..6cedb8766 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -112,7 +112,7 @@ namespace libtorrent , m_sync_bytes_read(0) , m_enc_send_buffer(0, 0) #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS , m_sent_bitfield(false) , m_in_constructor(true) , m_sent_handshake(false) @@ -150,7 +150,7 @@ namespace libtorrent , m_sync_bytes_read(0) , m_enc_send_buffer(0, 0) #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS , m_sent_bitfield(false) , m_in_constructor(true) , m_sent_handshake(false) @@ -289,7 +289,7 @@ namespace libtorrent { INVARIANT_CHECK; TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_sent_bitfield = true; #endif #ifdef TORRENT_VERBOSE_LOGGING @@ -303,7 +303,7 @@ namespace libtorrent { INVARIANT_CHECK; TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_sent_bitfield = true; #endif #ifdef TORRENT_VERBOSE_LOGGING @@ -790,7 +790,7 @@ namespace libtorrent INVARIANT_CHECK; TORRENT_ASSERT(!m_sent_handshake); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_sent_handshake = true; #endif @@ -2002,7 +2002,7 @@ namespace libtorrent // if we are super seeding, pretend to not have any piece // and don't send a bitfield -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_sent_bitfield = true; #endif @@ -2029,7 +2029,7 @@ namespace libtorrent #ifdef TORRENT_VERBOSE_LOGGING peer_log(" *** NOT SENDING BITFIELD"); #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_sent_bitfield = true; #endif return; @@ -2106,7 +2106,7 @@ namespace libtorrent } peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str()); #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_sent_bitfield = true; #endif @@ -3095,6 +3095,7 @@ namespace libtorrent if (!is_local()) write_handshake(); // if (t->valid_metadata()) // write_bitfield(); + TORRENT_ASSERT(m_sent_handshake); if (is_disconnecting()) return; @@ -3107,6 +3108,7 @@ namespace libtorrent // fall through if (m_state == read_peer_id) { + TORRENT_ASSERT(m_sent_handshake); m_statistics.received_bytes(0, bytes_transferred); bytes_transferred = 0; if (!t) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index fa9b4b309..bed389bae 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -161,7 +161,7 @@ namespace libtorrent , m_sent_suggests(false) , m_holepunch_mode(false) , m_ignore_stats(false) -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS , m_in_constructor(true) , m_disconnect_started(false) , m_initialized(false) @@ -304,7 +304,7 @@ namespace libtorrent , m_sent_suggests(false) , m_holepunch_mode(false) , m_ignore_stats(false) -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS , m_in_constructor(true) , m_disconnect_started(false) , m_initialized(false) @@ -812,7 +812,7 @@ namespace libtorrent m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all); 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; #endif // now that we have a piece_picker, @@ -2046,7 +2046,7 @@ namespace libtorrent TORRENT_ASSERT(m_outstanding_bytes >= bytes); m_outstanding_bytes -= bytes; if (m_outstanding_bytes < 0) m_outstanding_bytes = 0; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS boost::shared_ptr t = associated_torrent().lock(); TORRENT_ASSERT(m_received_in_piece + bytes <= t->block_size()); m_received_in_piece += bytes; @@ -2206,7 +2206,7 @@ namespace libtorrent { if ((*i)->on_piece(p, data)) { -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS TORRENT_ASSERT(m_received_in_piece == p.length); m_received_in_piece = 0; #endif @@ -2245,7 +2245,7 @@ namespace libtorrent // just ignore it if (t->is_seed()) { -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS TORRENT_ASSERT(m_received_in_piece == p.length); m_received_in_piece = 0; #endif @@ -2279,7 +2279,7 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING peer_log("*** The block we just got was not in the request queue ***"); #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS TORRENT_ASSERT_VAL(m_received_in_piece == p.length, m_received_in_piece); m_received_in_piece = 0; #endif @@ -2340,7 +2340,7 @@ namespace libtorrent b = m_download_queue.begin() + block_index; 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); m_received_in_piece = 0; #endif @@ -3309,7 +3309,7 @@ namespace libtorrent // 2 protocol error (client sent something invalid) void peer_connection::disconnect(error_code const& ec, int error) { -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_disconnect_started = true; #endif diff --git a/src/session_impl.cpp b/src/session_impl.cpp index c23676868..3f50de79c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2314,7 +2314,7 @@ namespace aux { boost::intrusive_ptr c( new bt_peer_connection(*this, s, endp, 0)); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS c->m_in_constructor = false; #endif