diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index b40b49f6a..22808c2ca 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -190,7 +190,7 @@ namespace libtorrent void incoming_connection(boost::shared_ptr const& s); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool is_network_thread() const { #if defined BOOST_HAS_PTHREADS @@ -1008,7 +1008,7 @@ namespace libtorrent // the main working thread boost::scoped_ptr m_thread; -#if defined TORRENT_DEBUG && defined BOOST_HAS_PTHREADS +#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && defined BOOST_HAS_PTHREADS pthread_t m_network_thread; #endif }; diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index 1720b757f..5dc85c959 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -64,7 +64,7 @@ struct TORRENT_EXPORT bandwidth_manager void close(); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool is_queued(bandwidth_socket const* peer) const; #endif diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 86aeeb10f..0713bc8d3 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -302,7 +302,7 @@ public: { TORRENT_ASSERT(send_buffer_size() == m_encrypted_bytes); m_RC4_handler->encrypt(buffer, size); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_encrypted_bytes += size; TORRENT_ASSERT(m_encrypted_bytes == send_buffer_size() + size); #endif @@ -445,7 +445,7 @@ private: boost::scoped_ptr m_sync_hash; #endif // #ifndef TORRENT_DISABLE_ENCRYPTION -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS // this is set to true when the client's // bitfield is sent to this peer bool m_sent_bitfield; diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 1ceb73289..cf00802dc 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -232,11 +232,11 @@ namespace libtorrent struct TORRENT_EXPORT disk_buffer_pool : boost::noncopyable { disk_buffer_pool(int block_size); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS ~disk_buffer_pool(); #endif -#if defined TORRENT_DEBUG || defined TORRENT_DISK_STATS +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || defined TORRENT_DISK_STATS bool is_disk_buffer(char* buffer , mutex::scoped_lock& l) const; bool is_disk_buffer(char* buffer) const; @@ -296,7 +296,7 @@ namespace libtorrent std::ofstream m_log; private: #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int m_magic; #endif }; diff --git a/include/libtorrent/kademlia/observer.hpp b/include/libtorrent/kademlia/observer.hpp index afe31ebff..051ae9e71 100644 --- a/include/libtorrent/kademlia/observer.hpp +++ b/include/libtorrent/kademlia/observer.hpp @@ -78,7 +78,7 @@ struct observer : boost::noncopyable , flags(0) { TORRENT_ASSERT(a); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_in_constructor = true; m_was_sent = false; #endif @@ -162,7 +162,7 @@ protected: public: unsigned char flags; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool m_in_constructor:1; bool m_was_sent:1; #endif diff --git a/include/libtorrent/kademlia/rpc_manager.hpp b/include/libtorrent/kademlia/rpc_manager.hpp index 1cd5759bc..9e738dce9 100644 --- a/include/libtorrent/kademlia/rpc_manager.hpp +++ b/include/libtorrent/kademlia/rpc_manager.hpp @@ -88,8 +88,10 @@ public: void add_our_id(entry& e); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS size_t allocation_size() const; +#endif +#ifdef TORRENT_DEBUG void check_invariant() const; #endif diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 421e38a5e..ca72170fe 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -1215,7 +1215,7 @@ namespace libtorrent ); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS public: bool m_in_constructor:1; bool m_disconnect_started:1; diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index ae57c44e7..af3bc684c 100644 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -144,9 +144,10 @@ namespace libtorrent void set_seed(policy::peer* p, bool s); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool has_connection(const peer_connection* p); - +#endif +#ifdef TORRENT_DEBUG void check_invariant() const; #endif diff --git a/include/libtorrent/udp_socket.hpp b/include/libtorrent/udp_socket.hpp index 6fa272eb6..dea2af217 100644 --- a/include/libtorrent/udp_socket.hpp +++ b/include/libtorrent/udp_socket.hpp @@ -164,7 +164,7 @@ namespace libtorrent void maybe_realloc_buffers(int which = 3); bool maybe_clear_callback(); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if defined BOOST_HAS_PTHREADS mutable pthread_t m_thread; #endif @@ -226,7 +226,7 @@ namespace libtorrent // operations hanging on this socket int m_outstanding_ops; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool m_started; int m_magic; int m_outstanding_when_aborted; diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index bee795466..7b6e2df55 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -223,12 +223,12 @@ private: , supports_specific_external(true) , disabled(false) { -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS magic = 1337; #endif } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS ~rootdevice() { TORRENT_ASSERT(magic == 1337); @@ -264,7 +264,7 @@ private: mutable boost::shared_ptr upnp_connection; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int magic; #endif void close() const diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index 5c79a25b1..a4ebd1f7f 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -313,7 +313,7 @@ public: ec = asio::error::would_block; return 0; } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS size_t buf_size = 0; #endif @@ -323,7 +323,7 @@ public: using asio::buffer_cast; using asio::buffer_size; add_read_buffer(buffer_cast(*i), buffer_size(*i)); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS buf_size += buffer_size(*i); #endif } diff --git a/src/bandwidth_manager.cpp b/src/bandwidth_manager.cpp index 8488e5c1a..9dbc5d2c1 100644 --- a/src/bandwidth_manager.cpp +++ b/src/bandwidth_manager.cpp @@ -59,7 +59,7 @@ namespace libtorrent m_queued_bytes = 0; } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool bandwidth_manager::is_queued(bandwidth_socket const* peer) const { for (queue_t::const_iterator i = m_queue.begin() diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 9a24d94a0..b431617c3 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -122,7 +122,7 @@ namespace libtorrent peer_log("*** bt_peer_connection"); #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_in_constructor = false; m_encrypted_bytes = 0; #endif @@ -174,7 +174,7 @@ namespace libtorrent m_quota[upload_channel] = 80; #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_in_constructor = false; m_encrypted_bytes = 0; #endif @@ -446,7 +446,7 @@ namespace libtorrent send_buf.begin); std::generate(send_buf.begin + dh_key_len, send_buf.end, std::rand); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_encrypted_bytes += send_buf.left(); TORRENT_ASSERT(m_encrypted_bytes <= send_buffer_size()); #endif @@ -532,7 +532,7 @@ namespace libtorrent write_pe_vc_cryptofield(send_buf, crypto_provide, pad_size); m_RC4_handler->encrypt(send_buf.end - encrypt_size, encrypt_size); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_encrypted_bytes = send_buffer_size(); #endif @@ -561,7 +561,7 @@ namespace libtorrent m_RC4_handler->encrypt(send_buf.end - buf_size, buf_size); TORRENT_ASSERT(send_buffer_size() - buf_size == m_encrypted_bytes); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_encrypted_bytes += buf_size; TORRENT_ASSERT(m_encrypted_bytes <= send_buffer_size()); #endif @@ -683,7 +683,7 @@ namespace libtorrent { TORRENT_ASSERT(!m_rc4_encrypted || send_buffer_size() == m_encrypted_bytes); m_RC4_handler->encrypt(const_cast(buf), size); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_encrypted_bytes += size; #endif } @@ -719,7 +719,7 @@ namespace libtorrent TORRENT_ASSERT(m_enc_send_buffer.end); TORRENT_ASSERT(m_RC4_handler); TORRENT_ASSERT(send_buffer_size() - m_enc_send_buffer.left() == m_encrypted_bytes); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_encrypted_bytes += m_enc_send_buffer.left(); TORRENT_ASSERT(m_encrypted_bytes <= send_buffer_size()); #endif @@ -2791,7 +2791,7 @@ namespace libtorrent return; } m_rc4_encrypted = true; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_encrypted_bytes = send_buffer_size(); #endif } @@ -3364,7 +3364,7 @@ namespace libtorrent std::remove_if(m_payloads.begin(), m_payloads.end(), range_below_zero) , m_payloads.end()); -#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_ENCRYPTION +#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && !defined TORRENT_DISABLE_ENCRYPTION if (m_encrypted_bytes > 0) { if (m_rc4_encrypted) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 3748a94fb..8f997cac7 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -86,12 +86,12 @@ namespace libtorrent m_disk_access_log.open("disk_access.log", std::ios::trunc); #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_magic = 0x1337; #endif } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS disk_buffer_pool::~disk_buffer_pool() { TORRENT_ASSERT(m_magic == 0x1337); @@ -99,7 +99,7 @@ namespace libtorrent } #endif -#if defined TORRENT_DEBUG || defined TORRENT_DISK_STATS +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || defined TORRENT_DISK_STATS bool disk_buffer_pool::is_disk_buffer(char* buffer , mutex::scoped_lock& l) const { diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index c7a7ba531..a711ec7c8 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -230,12 +230,13 @@ void rpc_manager::free_observer(void* ptr) m_pool_allocator.free(ptr); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS size_t rpc_manager::allocation_size() const { return observer_size; } - +#endif +#ifdef TORRENT_DEBUG void rpc_manager::check_invariant() const { for (transactions_t::const_iterator i = m_transactions.begin() @@ -470,7 +471,7 @@ bool rpc_manager::invoke(entry& e, udp::endpoint target_addr if (m_send(m_userdata, e, target_addr, 1)) { m_transactions.push_back(o); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS o->m_was_sent = true; #endif } diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 19d2e28d2..fa9b4b309 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2287,7 +2287,7 @@ namespace libtorrent return; } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS pending_block pending_b = *b; #endif diff --git a/src/policy.cpp b/src/policy.cpp index 94fe8001d..b651acef9 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -78,7 +78,7 @@ namespace tcp::endpoint const& m_ep; }; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS struct match_peer_connection { match_peer_connection(peer_connection const& c) : m_conn(c) {} @@ -1444,7 +1444,7 @@ namespace libtorrent } } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool policy::has_connection(const peer_connection* c) { INVARIANT_CHECK; @@ -1464,7 +1464,9 @@ namespace libtorrent , m_peers.end() , match_peer_connection_or_endpoint(*c)) != m_peers.end(); } +#endif +#ifdef TORRENT_DEBUG void policy::check_invariant() const { TORRENT_ASSERT(m_num_connect_candidates >= 0); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 394999c57..c23676868 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1476,7 +1476,7 @@ namespace aux { // abort all connections while (!m_connections.empty()) { -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int conn = m_connections.size(); #endif (*m_connections.begin())->disconnect(errors::stopping_torrent); @@ -4238,7 +4238,7 @@ namespace aux { if (options & session::delete_files) t.delete_files(); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS sha1_hash i_hash = t.torrent_file().info_hash(); #endif #ifndef TORRENT_DISABLE_DHT diff --git a/src/storage.cpp b/src/storage.cpp index d85fa0408..76bdee868 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -326,7 +326,7 @@ namespace libtorrent std::memset(i->iov_base, 0, i->iov_len); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int count_bufs(file::iovec_t const* bufs, int bytes) { int size = 0; @@ -1112,7 +1112,7 @@ ret: int size = bufs_size(bufs, num_bufs); TORRENT_ASSERT(size > 0); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS std::vector slices = files().map_block(slot, offset, size); TORRENT_ASSERT(!slices.empty()); @@ -1148,7 +1148,7 @@ ret: TORRENT_ASSERT(bytes_left >= 0); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int counter = 0; #endif @@ -1169,7 +1169,7 @@ ret: if (file_bytes_left == 0) continue; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS TORRENT_ASSERT(int(slices.size()) > counter); size_type slice_size = slices[counter].size; TORRENT_ASSERT(slice_size == file_bytes_left); diff --git a/src/torrent.cpp b/src/torrent.cpp index 76fb3089f..e3b8978b4 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -610,7 +610,7 @@ namespace libtorrent // update our torrent_info object and move the // torrent from the old info-hash to the new one // as we replace the torrent_info object -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int num_torrents = m_ses.m_torrents.size(); #endif // we're about to erase the session's reference to this @@ -718,7 +718,7 @@ namespace libtorrent // update our torrent_info object and move the // torrent from the old info-hash to the new one // as we replace the torrent_info object -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int num_torrents = m_ses.m_torrents.size(); #endif m_ses.m_torrents.erase(m_torrent_file->info_hash()); @@ -5237,7 +5237,7 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING (*p->m_logger) << "*** CLOSING CONNECTION: " << ec.message() << "\n"; #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS std::size_t size = m_connections.size(); #endif if (p->is_disconnecting()) @@ -5308,7 +5308,7 @@ namespace libtorrent peer_connection* p = *i; ++ret; TORRENT_ASSERT(p->associated_torrent().lock().get() == this); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS int num_conns = m_connections.size(); #endif p->disconnect(ec); diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index 1c0267e1e..de4ee85b7 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -82,7 +82,7 @@ udp_socket::udp_socket(asio::io_service& ios , m_abort(false) , m_outstanding_ops(0) { -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_magic = 0x1337; m_started = false; m_outstanding_when_aborted = -1; @@ -109,13 +109,13 @@ udp_socket::~udp_socket() TORRENT_ASSERT_VAL(m_v4_outstanding == 0, m_v4_outstanding); TORRENT_ASSERT(m_magic == 0x1337); TORRENT_ASSERT(!m_callback || !m_started); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_magic = 0; #endif TORRENT_ASSERT(m_outstanding_ops == 0); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #define CHECK_MAGIC check_magic_ cm_(m_magic) struct check_magic_ {