diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 09e160415..a07157ae0 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -1007,7 +1007,7 @@ namespace libtorrent // get to download again after the disk has been // blocked connection_map::iterator m_next_disk_peer; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 50f788559..c53f93be5 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -249,7 +249,7 @@ namespace libtorrent void on_connected(); void on_metadata(); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; ptime m_last_choke; #endif diff --git a/include/libtorrent/connection_queue.hpp b/include/libtorrent/connection_queue.hpp index f3785b11a..982ab8bbd 100644 --- a/include/libtorrent/connection_queue.hpp +++ b/include/libtorrent/connection_queue.hpp @@ -84,7 +84,7 @@ public: } #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 2952dcb83..74fb5ef83 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -259,7 +259,7 @@ namespace libtorrent void thread_fun(); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/include/libtorrent/packet_buffer.hpp b/include/libtorrent/packet_buffer.hpp index 759ee27d9..1feed8dae 100644 --- a/include/libtorrent/packet_buffer.hpp +++ b/include/libtorrent/packet_buffer.hpp @@ -94,7 +94,7 @@ namespace libtorrent index_type span() const { return (m_last - m_first) & 0xffff; } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index b9d601a38..6c772e4b2 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -533,8 +533,10 @@ namespace libtorrent void assign_bandwidth(int channel, int amount); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; +#endif +#if defined TORRENT_DEBUG ptime m_last_choke; #endif diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 36451da83..1c55cfa05 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -362,10 +362,12 @@ namespace libtorrent #ifdef TORRENT_DEBUG // used in debug mode void verify_priority(int start, int end, int prio) const; - void check_invariant(const torrent* t = 0) const; void verify_pick(std::vector const& picked , bitfield const& bits) const; #endif +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS + void check_invariant(const torrent* t = 0) const; +#endif #if defined TORRENT_PICKER_LOG void print_pieces() const; #endif diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index 14a0b094c..73190ee47 100644 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -150,7 +150,7 @@ namespace libtorrent #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS bool has_connection(const peer_connection* p); #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index f618d5386..225151f2c 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -460,11 +460,11 @@ namespace libtorrent int move_storage_impl(std::string const& save_path); int allocate_slot_for_piece(int piece_index); -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; +#endif #ifdef TORRENT_STORAGE_DEBUG void debug_log() const; -#endif #endif boost::intrusive_ptr m_info; file_storage const& m_files; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index b8de970e4..5431b904b 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -744,7 +744,7 @@ namespace libtorrent #endif // DEBUG -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 0de09f956..4fda18723 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -424,7 +424,7 @@ namespace libtorrent : m_torrent(t) {} -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/include/libtorrent/web_connection_base.hpp b/include/libtorrent/web_connection_base.hpp index feb079e4c..9af0d9d0f 100644 --- a/include/libtorrent/web_connection_base.hpp +++ b/include/libtorrent/web_connection_base.hpp @@ -129,7 +129,7 @@ namespace libtorrent void write_allow_fast(int) {} void write_suggest(int piece) {} -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif diff --git a/src/bandwidth_manager.cpp b/src/bandwidth_manager.cpp index 8cb77d9fe..5545d33e5 100644 --- a/src/bandwidth_manager.cpp +++ b/src/bandwidth_manager.cpp @@ -120,7 +120,7 @@ namespace libtorrent return 0; } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void bandwidth_manager::check_invariant() const { int queued = 0; diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index ae624ad1d..45854c3d5 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -3337,7 +3337,7 @@ namespace libtorrent } } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void bt_peer_connection::check_invariant() const { boost::shared_ptr t = associated_torrent().lock(); diff --git a/src/connection_queue.cpp b/src/connection_queue.cpp index df71ec0db..96aceffab 100644 --- a/src/connection_queue.cpp +++ b/src/connection_queue.cpp @@ -169,8 +169,7 @@ namespace libtorrent int connection_queue::limit() const { return m_half_open_limit; } -#ifdef TORRENT_DEBUG - +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void connection_queue::check_invariant() const { int num_connecting = 0; diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 06ab2bdf8..f7e2d6a9d 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -916,7 +916,7 @@ namespace libtorrent return ret; } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void disk_io_thread::check_invariant() const { int cached_write_blocks = 0; diff --git a/src/packet_buffer.cpp b/src/packet_buffer.cpp index da8eea280..c4a250d47 100644 --- a/src/packet_buffer.cpp +++ b/src/packet_buffer.cpp @@ -48,7 +48,7 @@ namespace libtorrent { , m_last(0) {} -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void packet_buffer::check_invariant() const { int count = 0; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 3c0e49df9..9ec84cc6e 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5573,7 +5573,7 @@ namespace libtorrent setup_send(); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS struct peer_count_t { peer_count_t(): num_peers(0), num_peers_with_timeouts(0), num_peers_with_nowant(0), num_not_requested(0) {} diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 1d522f15e..2dd765585 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -79,7 +79,7 @@ namespace libtorrent #ifdef TORRENT_PICKER_LOG std::cerr << "new piece_picker" << std::endl; #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS check_invariant(); #endif } @@ -273,8 +273,10 @@ namespace libtorrent } std::cerr << std::endl; } -#endif +#endif // TORRENT_PIECE_PICKER +#endif // TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void piece_picker::check_invariant(const torrent* t) const { #ifndef TORRENT_DEBUG_REFCOUNTS diff --git a/src/policy.cpp b/src/policy.cpp index 3e7b7585b..3248c6d64 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -1713,7 +1713,7 @@ namespace libtorrent } #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS 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 2bcb2bf31..c4f5985ef 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -6229,7 +6229,7 @@ retry: #endif } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void session_impl::check_invariant() const { TORRENT_ASSERT(is_network_thread()); diff --git a/src/storage.cpp b/src/storage.cpp index 4e8c59112..7cfbddfaf 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -2894,7 +2894,7 @@ ret: return m_slot_to_piece[slot]; } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void piece_manager::check_invariant() const { TORRENT_ASSERT(m_current_slot <= m_files.num_pieces()); diff --git a/src/torrent.cpp b/src/torrent.cpp index 5f61aafaf..64091d418 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6598,7 +6598,7 @@ namespace libtorrent return m_ses.settings(); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void torrent::check_invariant() const { for (std::deque::const_iterator i = m_time_critical_pieces.begin() diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 904e86368..931f6a9cd 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -267,8 +267,7 @@ namespace libtorrent } #endif -#ifdef TORRENT_DEBUG - +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void torrent_handle::check_invariant() const {} diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 43659fc98..08c21bfd1 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -1341,7 +1341,7 @@ namespace libtorrent // ------- end deprecation ------- #endif -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void torrent_info::check_invariant() const { for (file_storage::iterator i = m_files.begin() diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index cab9658eb..14eabe086 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -326,7 +326,7 @@ struct utp_socket_impl void check_receive_buffers() const; -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void check_invariant() const; #endif @@ -1479,8 +1479,6 @@ void utp_socket_impl::write_payload(boost::uint8_t* ptr, int size) if (size == 0) return; - ptime now = time_now_hires(); - int buffers_to_clear = 0; while (size > 0) { @@ -3309,7 +3307,7 @@ void utp_socket_impl::check_receive_buffers() const TORRENT_ASSERT(int(size) == m_receive_buffer_size); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void utp_socket_impl::check_invariant() const { for (int i = m_outbuf.cursor(); diff --git a/src/web_connection_base.cpp b/src/web_connection_base.cpp index d4697821e..69b22a2dd 100644 --- a/src/web_connection_base.cpp +++ b/src/web_connection_base.cpp @@ -188,7 +188,7 @@ namespace libtorrent } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS void web_connection_base::check_invariant() const { /* diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index 280dc00f1..8c522409d 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -157,7 +157,7 @@ boost::shared_ptr setup_picker( TEST_CHECK(avail == availability_vec[i]); } -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS p->check_invariant(); #endif return p; @@ -166,7 +166,7 @@ boost::shared_ptr setup_picker( bool verify_pick(boost::shared_ptr p , std::vector const& picked, bool allow_multi_blocks = false) { -#ifdef TORRENT_DEBUG +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS p->check_invariant(); #endif if (!allow_multi_blocks)