clean up assert related defines and debuf-only fields less error-prone. fix missing initialization in file_pool caused by mistake in defines under which the debug field was initialized

This commit is contained in:
Arvid Norberg 2014-01-19 19:45:50 +00:00
parent a5b5cf0f62
commit 702b68ecc4
39 changed files with 165 additions and 154 deletions

View File

@ -359,7 +359,7 @@ feature.compose <full-stats>off : <define>TORRENT_DISABLE_FULL_STATS ;
feature asserts : auto on off production system : composite propagated ; feature asserts : auto on off production system : composite propagated ;
feature.compose <asserts>on : <define>TORRENT_RELEASE_ASSERTS=1 ; feature.compose <asserts>on : <define>TORRENT_RELEASE_ASSERTS=1 ;
feature.compose <asserts>production : <define>TORRENT_PRODUCTION_ASSERTS=1 <define>TORRENT_RELEASE_ASSERTS=1 ; feature.compose <asserts>production : <define>TORRENT_PRODUCTION_ASSERTS=1 <define>TORRENT_RELEASE_ASSERTS=1 ;
feature.compose <asserts>off : <define>TORRENT_NO_ASSERTS=1 ; feature.compose <asserts>off : <define>TORRENT_USE_ASSERTS=0 ;
feature.compose <asserts>system : <define>TORRENT_USE_SYSTEM_ASSERTS=1 ; feature.compose <asserts>system : <define>TORRENT_USE_SYSTEM_ASSERTS=1 ;
feature windows-version : 2k xp vista win7 : composite propagated link-incompatible ; feature windows-version : 2k xp vista win7 : composite propagated link-incompatible ;

View File

@ -655,7 +655,7 @@ defines you can use to control the build.
| ``TORRENT_PRODUCTION_ASSERTS`` | Define to either 0 or 1. Enables assert logging | | ``TORRENT_PRODUCTION_ASSERTS`` | Define to either 0 or 1. Enables assert logging |
| | in release builds. | | | in release builds. |
+----------------------------------------+-------------------------------------------------+ +----------------------------------------+-------------------------------------------------+
| ``TORRENT_NO_ASSERTS`` | Disables all asserts. | | ``TORRENT_USE_ASSERTS`` | Define as 0 to disable asserts unconditionally. |
+----------------------------------------+-------------------------------------------------+ +----------------------------------------+-------------------------------------------------+
| ``TORRENT_USE_SYSTEM_ASSERTS`` | Uses the libc assert macro rather then the | | ``TORRENT_USE_SYSTEM_ASSERTS`` | Uses the libc assert macro rather then the |
| | custom one. | | | custom one. |

View File

@ -40,8 +40,7 @@ std::string demangle(char const* name);
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0); TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0);
#endif #endif
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) \ #if TORRENT_USE_ASSERTS
&& !TORRENT_NO_ASSERTS
#if TORRENT_PRODUCTION_ASSERTS #if TORRENT_PRODUCTION_ASSERTS
extern char const* libtorrent_assert_log; extern char const* libtorrent_assert_log;
@ -69,12 +68,12 @@ TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file
#define TORRENT_ASSERT_VAL(x, y) assert(x) #define TORRENT_ASSERT_VAL(x, y) assert(x)
#endif #endif
#else // TORRENT_DEBUG || TORENT_RELEASE_ASSERTS && !TORRENT_NO_ASSERTS #else // TORRENT_USE_ASSERTS
#define TORRENT_ASSERT(a) do {} while(false) #define TORRENT_ASSERT(a) do {} while(false)
#define TORRENT_ASSERT_VAL(a, b) do {} while(false) #define TORRENT_ASSERT_VAL(a, b) do {} while(false)
#endif // TORRENT_DEBUG || TORENT_RELEASE_ASSERTS && !TORRENT_NO_ASSERTS #endif // TORRENT_USE_ASSERTS
#endif #endif

View File

@ -229,7 +229,7 @@ namespace libtorrent
torrent*, void*)> ext); torrent*, void*)> ext);
void add_ses_extension(boost::shared_ptr<plugin> ext); void add_ses_extension(boost::shared_ptr<plugin> ext);
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool has_peer(peer_connection const* p) const bool has_peer(peer_connection const* p) const
{ {
TORRENT_ASSERT(is_network_thread()); TORRENT_ASSERT(is_network_thread());
@ -265,7 +265,7 @@ namespace libtorrent
void incoming_connection(boost::shared_ptr<socket_type> const& s); void incoming_connection(boost::shared_ptr<socket_type> const& s);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool is_network_thread() const bool is_network_thread() const
{ {
#if defined BOOST_HAS_PTHREADS #if defined BOOST_HAS_PTHREADS
@ -561,7 +561,7 @@ namespace libtorrent
--m_num_active_finished; --m_num_active_finished;
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool in_state_updates(boost::shared_ptr<torrent> t) bool in_state_updates(boost::shared_ptr<torrent> t)
{ {
return std::find_if(m_state_updates.begin(), m_state_updates.end() return std::find_if(m_state_updates.begin(), m_state_updates.end()
@ -1230,7 +1230,7 @@ namespace libtorrent
// the main working thread // the main working thread
boost::scoped_ptr<thread> m_thread; boost::scoped_ptr<thread> m_thread;
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && defined BOOST_HAS_PTHREADS #if TORRENT_USE_ASSERTS && defined BOOST_HAS_PTHREADS
pthread_t m_network_thread; pthread_t m_network_thread;
#endif #endif
}; };

View File

@ -64,7 +64,7 @@ struct TORRENT_EXTRA_EXPORT bandwidth_manager
void close(); void close();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool is_queued(bandwidth_socket const* peer) const; bool is_queued(bandwidth_socket const* peer) const;
#endif #endif

View File

@ -354,7 +354,7 @@ private:
bool m_supports_dht_port:1; bool m_supports_dht_port:1;
bool m_supports_fast:1; bool m_supports_fast:1;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
// this is set to true when the client's // this is set to true when the client's
// bitfield is sent to this peer // bitfield is sent to this peer
bool m_sent_bitfield:1; bool m_sent_bitfield:1;

View File

@ -54,7 +54,7 @@ namespace libtorrent
{ {
chained_buffer(): m_bytes(0), m_capacity(0) chained_buffer(): m_bytes(0), m_capacity(0)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_destructed = false; m_destructed = false;
#endif #endif
} }
@ -114,7 +114,7 @@ namespace libtorrent
// including unused space // including unused space
int m_capacity; int m_capacity;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool m_destructed; bool m_destructed;
#endif #endif
}; };

View File

@ -57,7 +57,7 @@ POSSIBILITY OF SUCH DAMAGE.
#if !defined BOOST_ASIO_SEPARATE_COMPILATION && !defined BOOST_ASIO_DYN_LINK #if !defined BOOST_ASIO_SEPARATE_COMPILATION && !defined BOOST_ASIO_DYN_LINK
#error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO_DYN_LINK in your project in \ #error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO_DYN_LINK in your project in \
order for asios declarations to be correct. If you are linking dynamically against libtorrent, define \ order for asio's declarations to be correct. If you are linking dynamically against libtorrent, define \
BOOST_ASIO_DYN_LINK otherwise BOOST_ASIO_SEPARATE_COMPILATION. You can also use pkg-config or boost \ BOOST_ASIO_DYN_LINK otherwise BOOST_ASIO_SEPARATE_COMPILATION. You can also use pkg-config or boost \
build, to automatically apply these defines build, to automatically apply these defines
#endif #endif
@ -569,6 +569,17 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
#endif #endif
// debug builds have asserts enabled by default, release
// builds have asserts if they are explicitly enabled by
// the release_asserts macro.
#ifndef TORRENT_USE_ASSERTS
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#define TORRENT_USE_ASSERTS 1
#else
#define TORRENT_USE_ASSERTS 0
#endif
#endif // TORRENT_USE_ASSERTS
// for non-exception builds // for non-exception builds
#ifdef BOOST_NO_EXCEPTIONS #ifdef BOOST_NO_EXCEPTIONS
#define TORRENT_TRY if (true) #define TORRENT_TRY if (true)

View File

@ -48,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <fstream> #include <fstream>
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || TORRENT_DISK_STATS #if TORRENT_USE_ASSERTS || TORRENT_DISK_STATS
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#endif #endif
@ -57,11 +57,11 @@ namespace libtorrent
struct TORRENT_EXTRA_EXPORT disk_buffer_pool : boost::noncopyable struct TORRENT_EXTRA_EXPORT disk_buffer_pool : boost::noncopyable
{ {
disk_buffer_pool(int block_size); disk_buffer_pool(int block_size);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
~disk_buffer_pool(); ~disk_buffer_pool();
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || defined TORRENT_DISK_STATS #if TORRENT_USE_ASSERTS || TORRENT_DISK_STATS
bool is_disk_buffer(char* buffer bool is_disk_buffer(char* buffer
, mutex::scoped_lock& l) const; , mutex::scoped_lock& l) const;
bool is_disk_buffer(char* buffer) const; bool is_disk_buffer(char* buffer) const;
@ -134,7 +134,7 @@ namespace libtorrent
std::ofstream m_log; std::ofstream m_log;
private: private:
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int m_magic; int m_magic;
#endif #endif
}; };

View File

@ -107,7 +107,7 @@ namespace libtorrent
file_set m_files; file_set m_files;
mutex m_mutex; mutex m_mutex;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int m_in_use; int m_in_use;
#endif #endif

View File

@ -156,7 +156,7 @@ private:
}; };
int m_state; int m_state;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int m_magic; int m_magic;
#endif #endif
}; };

View File

@ -90,7 +90,7 @@ public:
void add_our_id(entry& e); void add_our_id(entry& e);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
size_t allocation_size() const; size_t allocation_size() const;
#endif #endif
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG

View File

@ -1308,7 +1308,7 @@ namespace libtorrent
); );
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
public: public:
bool m_in_constructor:1; bool m_in_constructor:1;
bool m_disconnect_started:1; bool m_disconnect_started:1;

View File

@ -123,7 +123,7 @@ namespace libtorrent
// the state of this block // the state of this block
enum { state_none, state_requested, state_writing, state_finished }; enum { state_none, state_requested, state_writing, state_finished };
unsigned state:2; unsigned state:2;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
// to allow verifying the invariant of blocks belonging to the right piece // to allow verifying the invariant of blocks belonging to the right piece
int piece_index; int piece_index;
#endif #endif

View File

@ -147,7 +147,7 @@ namespace libtorrent
void set_seed(policy::peer* p, bool s); void set_seed(policy::peer* p, bool s);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool has_connection(const peer_connection* p); bool has_connection(const peer_connection* p);
#endif #endif
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS #if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
@ -313,7 +313,7 @@ namespace libtorrent
// so, any peer with the web_seed bit set, is // so, any peer with the web_seed bit set, is
// never considered a connect candidate // never considered a connect candidate
bool web_seed:1; bool web_seed:1;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool in_use:1; bool in_use:1;
#endif #endif
}; };

View File

@ -144,7 +144,7 @@ namespace libtorrent
peer_connection* find_lowest_ranking_peer() const; peer_connection* find_lowest_ranking_peer() const;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool has_peer(peer_connection* p) const bool has_peer(peer_connection* p) const
{ return m_connections.find(p) != m_connections.end(); } { return m_connections.find(p) != m_connections.end(); }
#endif #endif
@ -1417,7 +1417,7 @@ namespace libtorrent
// millionths of completeness) // millionths of completeness)
unsigned int m_progress_ppm:20; unsigned int m_progress_ppm:20;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
public: public:
// set to false until we've loaded resume data // set to false until we've loaded resume data
bool m_resume_data_loaded; bool m_resume_data_loaded;

View File

@ -201,7 +201,7 @@ namespace libtorrent
void wrap(char const* hostname, int port, char const* p, int len, error_code& ec); void wrap(char const* hostname, int port, char const* p, int len, error_code& ec);
void unwrap(error_code const& e, char const* buf, int size); void unwrap(error_code const& e, char const* buf, int size);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
#if defined BOOST_HAS_PTHREADS #if defined BOOST_HAS_PTHREADS
mutable pthread_t m_thread; mutable pthread_t m_thread;
@ -274,7 +274,7 @@ namespace libtorrent
#endif #endif
bool m_v4_write_subscribed:1; bool m_v4_write_subscribed:1;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool m_started; bool m_started;
int m_magic; int m_magic;
int m_outstanding_when_aborted; int m_outstanding_when_aborted;

View File

@ -267,12 +267,12 @@ private:
, supports_specific_external(true) , supports_specific_external(true)
, disabled(false) , disabled(false)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
magic = 1337; magic = 1337;
#endif #endif
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
~rootdevice() ~rootdevice()
{ {
TORRENT_ASSERT(magic == 1337); TORRENT_ASSERT(magic == 1337);
@ -308,7 +308,7 @@ private:
mutable boost::shared_ptr<http_connection> upnp_connection; mutable boost::shared_ptr<http_connection> upnp_connection;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int magic; int magic;
#endif #endif
void close() const void close() const

View File

@ -351,7 +351,7 @@ public:
ec = asio::error::would_block; ec = asio::error::would_block;
return 0; return 0;
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
size_t buf_size = 0; size_t buf_size = 0;
#endif #endif
@ -361,7 +361,7 @@ public:
using asio::buffer_cast; using asio::buffer_cast;
using asio::buffer_size; using asio::buffer_size;
add_read_buffer(buffer_cast<void*>(*i), buffer_size(*i)); add_read_buffer(buffer_cast<void*>(*i), buffer_size(*i));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
buf_size += buffer_size(*i); buf_size += buffer_size(*i);
#endif #endif
} }

View File

@ -206,7 +206,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth) {}
#endif #endif
#if (defined TORRENT_DEBUG && !TORRENT_NO_ASSERTS) || defined TORRENT_ASIO_DEBUGGING || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS || defined TORRENT_ASIO_DEBUGGING
#if TORRENT_PRODUCTION_ASSERTS #if TORRENT_PRODUCTION_ASSERTS
char const* libtorrent_assert_log = "asserts.log"; char const* libtorrent_assert_log = "asserts.log";

View File

@ -59,7 +59,7 @@ namespace libtorrent
m_queued_bytes = 0; m_queued_bytes = 0;
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool bandwidth_manager::is_queued(bandwidth_socket const* peer) const bool bandwidth_manager::is_queued(bandwidth_socket const* peer) const
{ {
for (queue_t::const_iterator i = m_queue.begin() for (queue_t::const_iterator i = m_queue.begin()

View File

@ -109,7 +109,7 @@ namespace libtorrent
, m_supports_extensions(false) , m_supports_extensions(false)
, m_supports_dht_port(false) , m_supports_dht_port(false)
, m_supports_fast(false) , m_supports_fast(false)
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_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)
@ -134,7 +134,7 @@ namespace libtorrent
peer_log("*** bt_peer_connection"); peer_log("*** bt_peer_connection");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_in_constructor = false; m_in_constructor = false;
#endif #endif
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -264,7 +264,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
@ -278,7 +278,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
@ -710,7 +710,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(!m_sent_handshake); TORRENT_ASSERT(!m_sent_handshake);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_sent_handshake = true; m_sent_handshake = true;
#endif #endif
@ -1969,7 +1969,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
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
@ -1996,7 +1996,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
peer_log(" *** NOT SENDING BITFIELD"); peer_log(" *** NOT SENDING BITFIELD");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
return; return;
@ -2071,7 +2071,7 @@ namespace libtorrent
} }
peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str()); peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str());
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif

View File

@ -137,7 +137,7 @@ namespace libtorrent
chained_buffer::~chained_buffer() chained_buffer::~chained_buffer()
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(!m_destructed); TORRENT_ASSERT(!m_destructed);
m_destructed = true; m_destructed = true;
#endif #endif

View File

@ -62,12 +62,12 @@ namespace libtorrent
m_disk_access_log.open("disk_access.log", std::ios::trunc); m_disk_access_log.open("disk_access.log", std::ios::trunc);
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_magic = 0x1337; m_magic = 0x1337;
#endif #endif
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
disk_buffer_pool::~disk_buffer_pool() disk_buffer_pool::~disk_buffer_pool()
{ {
TORRENT_ASSERT(m_magic == 0x1337); TORRENT_ASSERT(m_magic == 0x1337);
@ -75,7 +75,7 @@ namespace libtorrent
} }
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || defined TORRENT_DISK_STATS #if TORRENT_USE_ASSERTS || defined TORRENT_DISK_STATS
bool disk_buffer_pool::is_disk_buffer(char* buffer bool disk_buffer_pool::is_disk_buffer(char* buffer
, mutex::scoped_lock& l) const , mutex::scoped_lock& l) const
{ {

View File

@ -49,14 +49,14 @@ namespace libtorrent
, m_closer_thread(boost::bind(&file_pool::closer_thread_fun, this)) , m_closer_thread(boost::bind(&file_pool::closer_thread_fun, this))
#endif #endif
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
m_in_use = 1337; m_in_use = 1337;
#endif #endif
} }
file_pool::~file_pool() file_pool::~file_pool()
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
m_in_use = 0; m_in_use = 0;
#endif #endif
#if TORRENT_CLOSE_MAY_BLOCK #if TORRENT_CLOSE_MAY_BLOCK

View File

@ -188,14 +188,14 @@ namespace libtorrent
, m_command(cmd_create_session) , m_command(cmd_create_session)
, m_state(0) , m_state(0)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_magic = 0x1337; m_magic = 0x1337;
#endif #endif
} }
i2p_stream::~i2p_stream() i2p_stream::~i2p_stream()
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_magic == 0x1337); TORRENT_ASSERT(m_magic == 0x1337);
m_magic = 0; m_magic = 0;
#endif #endif

View File

@ -30,11 +30,12 @@ POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <libtorrent/config.hpp>
#include <libtorrent/hasher.hpp> #include <libtorrent/hasher.hpp>
#include <libtorrent/kademlia/get_item.hpp> #include <libtorrent/kademlia/get_item.hpp>
#include <libtorrent/kademlia/node.hpp> #include <libtorrent/kademlia/node.hpp>
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && !TORRENT_NO_ASSERTS #if TORRENT_USE_ASSERTS
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#endif #endif
@ -65,7 +66,7 @@ void get_item::got_data(lazy_entry const* v,
bool put_requested = m_data_callback(m_data); bool put_requested = m_data_callback(m_data);
if (put_requested) if (put_requested)
{ {
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && !TORRENT_NO_ASSERTS #if TORRENT_USE_ASSERTS
std::vector<char> buffer; std::vector<char> buffer;
bencode(std::back_inserter(buffer), m_data.value()); bencode(std::back_inserter(buffer), m_data.value());
TORRENT_ASSERT(m_target == hasher(&buffer[0], buffer.size()).final()); TORRENT_ASSERT(m_target == hasher(&buffer[0], buffer.size()).final());
@ -97,7 +98,7 @@ observer_ptr get_item::new_observer(void* ptr
, udp::endpoint const& ep, node_id const& id) , udp::endpoint const& ep, node_id const& id)
{ {
observer_ptr o(new (ptr) get_item_observer(this, ep, id)); observer_ptr o(new (ptr) get_item_observer(this, ep, id));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
return o; return o;
@ -128,7 +129,7 @@ void get_item::done()
bool put_requested = m_data_callback(m_data); bool put_requested = m_data_callback(m_data);
if (put_requested) if (put_requested)
{ {
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && !TORRENT_NO_ASSERTS #if TORRENT_USE_ASSERTS
if (m_data.is_mutable()) if (m_data.is_mutable())
{ {
TORRENT_ASSERT(m_target == hasher(m_data.pk(), item_pk_len).final()); TORRENT_ASSERT(m_target == hasher(m_data.pk(), item_pk_len).final());
@ -169,7 +170,7 @@ void get_item::put(std::vector<std::pair<node_entry, std::string> > const& v)
void* ptr = m_node.m_rpc.allocate_observer(); void* ptr = m_node.m_rpc.allocate_observer();
if (ptr == 0) return; if (ptr == 0) return;
observer_ptr o(new (ptr) announce_observer(algo, i->first.ep(), i->first.id)); observer_ptr o(new (ptr) announce_observer(algo, i->first.ep(), i->first.id));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
entry e; entry e;

View File

@ -149,7 +149,7 @@ observer_ptr get_peers::new_observer(void* ptr
, udp::endpoint const& ep, node_id const& id) , udp::endpoint const& ep, node_id const& id)
{ {
observer_ptr o(new (ptr) get_peers_observer(this, ep, id)); observer_ptr o(new (ptr) get_peers_observer(this, ep, id));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
return o; return o;
@ -175,7 +175,7 @@ observer_ptr obfuscated_get_peers::new_observer(void* ptr
if (m_obfuscated) if (m_obfuscated)
{ {
observer_ptr o(new (ptr) obfuscated_get_peers_observer(this, ep, id)); observer_ptr o(new (ptr) obfuscated_get_peers_observer(this, ep, id));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
return o; return o;
@ -183,7 +183,7 @@ observer_ptr obfuscated_get_peers::new_observer(void* ptr
else else
{ {
observer_ptr o(new (ptr) get_peers_observer(this, ep, id)); observer_ptr o(new (ptr) get_peers_observer(this, ep, id));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
return o; return o;

View File

@ -225,7 +225,7 @@ void rpc_manager::free_observer(void* ptr)
m_pool_allocator.free(ptr); m_pool_allocator.free(ptr);
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
size_t rpc_manager::allocation_size() const size_t rpc_manager::allocation_size() const
{ {
return observer_size; return observer_size;
@ -393,7 +393,7 @@ time_duration rpc_manager::tick()
time_duration ret = seconds(short_timeout); time_duration ret = seconds(short_timeout);
ptime now = time_now(); ptime now = time_now();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
ptime last = min_time(); ptime last = min_time();
for (transactions_t::iterator i = m_transactions.begin(); for (transactions_t::iterator i = m_transactions.begin();
i != m_transactions.end(); ++i) i != m_transactions.end(); ++i)
@ -490,7 +490,7 @@ bool rpc_manager::invoke(entry& e, udp::endpoint target_addr
if (m_sock->send_packet(e, target_addr, 1)) if (m_sock->send_packet(e, target_addr, 1))
{ {
m_transactions.push_back(o); m_transactions.push_back(o);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
o->m_was_sent = true; o->m_was_sent = true;
#endif #endif
return true; return true;
@ -506,7 +506,7 @@ observer::~observer()
// reported back // reported back
TORRENT_ASSERT(m_was_sent == bool(flags & flag_done) || m_was_abandoned); TORRENT_ASSERT(m_was_sent == bool(flags & flag_done) || m_was_abandoned);
TORRENT_ASSERT(!m_in_constructor); TORRENT_ASSERT(!m_in_constructor);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_in_use); TORRENT_ASSERT(m_in_use);
m_in_use = false; m_in_use = false;
#endif #endif

View File

@ -59,7 +59,7 @@ observer_ptr traversal_algorithm::new_observer(void* ptr
, udp::endpoint const& ep, node_id const& id) , udp::endpoint const& ep, node_id const& id)
{ {
observer_ptr o(new (ptr) null_observer(boost::intrusive_ptr<traversal_algorithm>(this), ep, id)); observer_ptr o(new (ptr) null_observer(boost::intrusive_ptr<traversal_algorithm>(this), ep, id));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
return o; return o;
@ -170,7 +170,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig
if (m_results.size() > 100) if (m_results.size() > 100)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
for (int i = 100; i < m_results.size(); ++i) for (int i = 100; i < m_results.size(); ++i)
m_results[i]->m_was_abandoned = true; m_results[i]->m_was_abandoned = true;
#endif #endif

View File

@ -191,7 +191,7 @@ namespace libtorrent
, m_upload_only(false) , m_upload_only(false)
, m_snubbed(false) , m_snubbed(false)
, m_no_download(false) , m_no_download(false)
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
, m_in_constructor(true) , m_in_constructor(true)
, m_disconnect_started(false) , m_disconnect_started(false)
, m_initialized(false) , m_initialized(false)
@ -705,7 +705,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();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(!m_initialized); TORRENT_ASSERT(!m_initialized);
m_initialized = true; m_initialized = true;
#endif #endif
@ -761,7 +761,7 @@ namespace libtorrent
TORRENT_ASSERT(m_disconnect_started); TORRENT_ASSERT(m_disconnect_started);
TORRENT_ASSERT(m_ses.is_network_thread()); TORRENT_ASSERT(m_ses.is_network_thread());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_in_use = 0; m_in_use = 0;
#endif #endif
@ -792,7 +792,7 @@ namespace libtorrent
// TORRENT_ASSERT(!m_ses.has_peer(this)); // TORRENT_ASSERT(!m_ses.has_peer(this));
TORRENT_ASSERT(m_request_queue.empty()); TORRENT_ASSERT(m_request_queue.empty());
TORRENT_ASSERT(m_download_queue.empty()); TORRENT_ASSERT(m_download_queue.empty());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin() for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin()
, end(m_ses.m_torrents.end()); i != end; ++i) , end(m_ses.m_torrents.end()); i != end; ++i)
TORRENT_ASSERT(!i->second->has_peer(this)); TORRENT_ASSERT(!i->second->has_peer(this));
@ -900,7 +900,7 @@ namespace libtorrent
peer_log("==> HAVE [ piece: %d ]", index); peer_log("==> HAVE [ piece: %d ]", index);
#endif #endif
write_have(index); write_have(index);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
boost::shared_ptr<torrent> t = m_torrent.lock(); boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#endif #endif
@ -2115,7 +2115,7 @@ namespace libtorrent
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;
boost::shared_ptr<torrent> t = associated_torrent().lock(); boost::shared_ptr<torrent> t = associated_torrent().lock();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
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;
#endif #endif
@ -2133,7 +2133,7 @@ namespace libtorrent
#if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_DEBUG #if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_DEBUG
check_invariant(); check_invariant();
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
buffer::const_interval recv_buffer = receive_buffer(); buffer::const_interval recv_buffer = receive_buffer();
int recv_pos = recv_buffer.end - recv_buffer.begin; int recv_pos = recv_buffer.end - recv_buffer.begin;
TORRENT_ASSERT(recv_pos >= 9); TORRENT_ASSERT(recv_pos >= 9);
@ -2296,7 +2296,7 @@ namespace libtorrent
{ {
if ((*i)->on_piece(p, data)) if ((*i)->on_piece(p, data))
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_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
@ -2338,7 +2338,7 @@ namespace libtorrent
// just ignore it // just ignore it
if (t->is_seed()) if (t->is_seed())
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_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
@ -2372,7 +2372,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
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_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
@ -2380,7 +2380,7 @@ namespace libtorrent
return; return;
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
pending_block pending_b = *b; pending_block pending_b = *b;
#endif #endif
@ -2433,7 +2433,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);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_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
@ -2529,7 +2529,7 @@ namespace libtorrent
t->check_invariant(); t->check_invariant();
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
piece_picker::downloading_piece pi; piece_picker::downloading_piece pi;
picker.piece_info(p.piece, pi); picker.piece_info(p.piece, pi);
int num_blocks = picker.blocks_in_piece(p.piece); int num_blocks = picker.blocks_in_piece(p.piece);
@ -2887,7 +2887,7 @@ namespace libtorrent
std::vector<pending_block>::iterator rit = std::find_if(m_request_queue.begin() std::vector<pending_block>::iterator rit = std::find_if(m_request_queue.begin()
, m_request_queue.end(), has_block(block)); , m_request_queue.end(), has_block(block));
if (rit == m_request_queue.end()) return; if (rit == m_request_queue.end()) return;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
boost::shared_ptr<torrent> t = m_torrent.lock(); boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->has_picker()); TORRENT_ASSERT(t->has_picker());
@ -3470,7 +3470,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)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_disconnect_started = true; m_disconnect_started = true;
#endif #endif
@ -5331,7 +5331,7 @@ namespace libtorrent
TORRENT_ASSERT(m_recv_pos <= int(m_recv_buffer.size() TORRENT_ASSERT(m_recv_pos <= int(m_recv_buffer.size()
+ m_disk_recv_buffer_size)); + m_disk_recv_buffer_size));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
size_type cur_payload_dl = m_statistics.last_payload_downloaded(); size_type cur_payload_dl = m_statistics.last_payload_downloaded();
size_type cur_protocol_dl = m_statistics.last_protocol_downloaded(); size_type cur_protocol_dl = m_statistics.last_protocol_downloaded();
#endif #endif
@ -5339,7 +5339,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
on_receive(error, bytes_transferred); on_receive(error, bytes_transferred);
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_statistics.last_payload_downloaded() - cur_payload_dl >= 0); TORRENT_ASSERT(m_statistics.last_payload_downloaded() - cur_payload_dl >= 0);
TORRENT_ASSERT(m_statistics.last_protocol_downloaded() - cur_protocol_dl >= 0); TORRENT_ASSERT(m_statistics.last_protocol_downloaded() - cur_protocol_dl >= 0);
size_type stats_diff = m_statistics.last_payload_downloaded() - cur_payload_dl + size_type stats_diff = m_statistics.last_payload_downloaded() - cur_payload_dl +
@ -5432,7 +5432,7 @@ namespace libtorrent
void peer_connection::on_connect(int ticket) void peer_connection::on_connect(int ticket)
{ {
TORRENT_ASSERT(m_ses.is_network_thread()); TORRENT_ASSERT(m_ses.is_network_thread());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
// in case we disconnect here, we need to // in case we disconnect here, we need to
// keep the connection alive until the // keep the connection alive until the
// exit invariant check is run // exit invariant check is run
@ -5713,12 +5713,12 @@ namespace libtorrent
m_last_sent = time_now(); m_last_sent = time_now();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
size_type cur_payload_ul = m_statistics.last_payload_uploaded(); size_type cur_payload_ul = m_statistics.last_payload_uploaded();
size_type cur_protocol_ul = m_statistics.last_protocol_uploaded(); size_type cur_protocol_ul = m_statistics.last_protocol_uploaded();
#endif #endif
on_sent(error, bytes_transferred); on_sent(error, bytes_transferred);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_statistics.last_payload_uploaded() - cur_payload_ul >= 0); TORRENT_ASSERT(m_statistics.last_payload_uploaded() - cur_payload_ul >= 0);
TORRENT_ASSERT(m_statistics.last_protocol_uploaded() - cur_protocol_ul >= 0); TORRENT_ASSERT(m_statistics.last_protocol_uploaded() - cur_protocol_ul >= 0);
size_type stats_diff = m_statistics.last_payload_uploaded() - cur_payload_ul size_type stats_diff = m_statistics.last_payload_uploaded() - cur_payload_ul

View File

@ -44,7 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/bitfield.hpp" #include "libtorrent/bitfield.hpp"
#include "libtorrent/random.hpp" #include "libtorrent/random.hpp"
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
#include "libtorrent/peer_connection.hpp" #include "libtorrent/peer_connection.hpp"
#include "libtorrent/torrent.hpp" #include "libtorrent/torrent.hpp"
#include "libtorrent/policy.hpp" // for policy::peer #include "libtorrent/policy.hpp" // for policy::peer
@ -206,7 +206,7 @@ namespace libtorrent
#ifdef TORRENT_USE_VALGRIND #ifdef TORRENT_USE_VALGRIND
VALGRIND_CHECK_VALUE_IS_DEFINED(ret.info[i].peer); VALGRIND_CHECK_VALUE_IS_DEFINED(ret.info[i].peer);
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
ret.info[i].piece_index = piece; ret.info[i].piece_index = piece;
#endif #endif
} }
@ -1061,7 +1061,7 @@ namespace libtorrent
int index = 0; int index = 0;
bool updated = false; bool updated = false;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool seed_broken = false; bool seed_broken = false;
#endif #endif
for (bitfield::const_iterator i = bitmask.begin() for (bitfield::const_iterator i = bitmask.begin()
@ -1084,7 +1084,7 @@ namespace libtorrent
// piece anymore. we need to break up one of the seed // piece anymore. we need to break up one of the seed
// counters into actual peer counters on the pieces // counters into actual peer counters on the pieces
break_one_seed(); break_one_seed();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
seed_broken = true; seed_broken = true;
#endif #endif
} }

View File

@ -81,7 +81,7 @@ namespace
tcp::endpoint const& m_ep; tcp::endpoint const& m_ep;
}; };
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
struct match_peer_connection struct match_peer_connection
{ {
match_peer_connection(peer_connection const& c) : m_conn(c) {} match_peer_connection(peer_connection const& c) : m_conn(c) {}
@ -530,7 +530,7 @@ namespace libtorrent
if (m_round_robin > i - m_peers.begin()) --m_round_robin; if (m_round_robin > i - m_peers.begin()) --m_round_robin;
if (m_round_robin >= int(m_peers.size())) m_round_robin = 0; if (m_round_robin >= int(m_peers.size())) m_round_robin = 0;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT((*i)->in_use); TORRENT_ASSERT((*i)->in_use);
(*i)->in_use = false; (*i)->in_use = false;
#endif #endif
@ -1095,7 +1095,7 @@ namespace libtorrent
#endif #endif
new (p) ipv4_peer(c.remote(), false, 0); new (p) ipv4_peer(c.remote(), false, 0);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
p->in_use = true; p->in_use = true;
#endif #endif
@ -1399,13 +1399,13 @@ namespace libtorrent
m_torrent->session().m_i2p_peer_pool.set_next_size(500); m_torrent->session().m_i2p_peer_pool.set_next_size(500);
new (p) i2p_peer(destination, true, src); new (p) i2p_peer(destination, true, src);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
p->in_use = true; p->in_use = true;
#endif #endif
if (!insert_peer(p, iter, flags)) if (!insert_peer(p, iter, flags))
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
p->in_use = false; p->in_use = false;
#endif #endif
@ -1532,13 +1532,13 @@ namespace libtorrent
#endif #endif
new (p) ipv4_peer(remote, true, src); new (p) ipv4_peer(remote, true, src);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
p->in_use = true; p->in_use = true;
#endif #endif
if (!insert_peer(p, iter, flags)) if (!insert_peer(p, iter, flags))
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
p->in_use = false; p->in_use = false;
#endif #endif
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
@ -1700,7 +1700,7 @@ namespace libtorrent
} }
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool policy::has_connection(const peer_connection* c) bool policy::has_connection(const peer_connection* c)
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
@ -1889,7 +1889,7 @@ namespace libtorrent
, confirmed_supports_utp(false) , confirmed_supports_utp(false)
, supports_holepunch(false) , supports_holepunch(false)
, web_seed(false) , web_seed(false)
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
, in_use(false) , in_use(false)
#endif #endif
{ {

View File

@ -688,11 +688,11 @@ namespace aux {
, m_abort(false) , m_abort(false)
, m_paused(false) , m_paused(false)
, m_incoming_connection(false) , m_incoming_connection(false)
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && defined BOOST_HAS_PTHREADS #if TORRENT_USE_ASSERTS && defined BOOST_HAS_PTHREADS
, m_network_thread(0) , m_network_thread(0)
#endif #endif
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_posting_torrent_updates = false; m_posting_torrent_updates = false;
#endif #endif
@ -1723,7 +1723,7 @@ namespace aux {
// abort all connections // abort all connections
while (!m_connections.empty()) while (!m_connections.empty())
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int conn = m_connections.size(); int conn = m_connections.size();
#endif #endif
(*m_connections.begin())->disconnect(errors::stopping_torrent); (*m_connections.begin())->disconnect(errors::stopping_torrent);
@ -2849,7 +2849,7 @@ retry:
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));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
c->m_in_constructor = false; c->m_in_constructor = false;
#endif #endif
@ -4801,7 +4801,7 @@ retry:
// it hard to debug stuff // it hard to debug stuff
::_set_se_translator(straight_to_debugger); ::_set_se_translator(straight_to_debugger);
#endif #endif
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && defined BOOST_HAS_PTHREADS #if TORRENT_USE_ASSERTS && defined BOOST_HAS_PTHREADS
m_network_thread = pthread_self(); m_network_thread = pthread_self();
#endif #endif
TORRENT_ASSERT(is_network_thread()); TORRENT_ASSERT(is_network_thread());
@ -4848,7 +4848,7 @@ retry:
TORRENT_ASSERT(m_torrents.empty()); TORRENT_ASSERT(m_torrents.empty());
TORRENT_ASSERT(m_connections.empty()); TORRENT_ASSERT(m_connections.empty());
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && defined BOOST_HAS_PTHREADS #if TORRENT_USE_ASSERTS && defined BOOST_HAS_PTHREADS
m_network_thread = 0; m_network_thread = 0;
#endif #endif
} }
@ -4973,7 +4973,7 @@ retry:
std::auto_ptr<state_update_alert> alert(new state_update_alert()); std::auto_ptr<state_update_alert> alert(new state_update_alert());
alert->status.reserve(m_state_updates.size()); alert->status.reserve(m_state_updates.size());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_posting_torrent_updates = true; m_posting_torrent_updates = true;
#endif #endif
@ -4988,7 +4988,7 @@ retry:
} }
m_state_updates.clear(); m_state_updates.clear();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_posting_torrent_updates = false; m_posting_torrent_updates = false;
#endif #endif
@ -5350,7 +5350,7 @@ retry:
tptr->update_guage(); tptr->update_guage();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
sha1_hash i_hash = t.torrent_file().info_hash(); sha1_hash i_hash = t.torrent_file().info_hash();
#endif #endif
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT

View File

@ -277,7 +277,7 @@ namespace libtorrent
std::memset(i->iov_base, 0, i->iov_len); std::memset(i->iov_base, 0, i->iov_len);
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int count_bufs(file::iovec_t const* bufs, int bytes) int count_bufs(file::iovec_t const* bufs, int bytes)
{ {
int size = 0; int size = 0;
@ -1127,7 +1127,7 @@ ret:
int size = bufs_size(bufs, num_bufs); int size = bufs_size(bufs, num_bufs);
TORRENT_ASSERT(size > 0); TORRENT_ASSERT(size > 0);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
std::vector<file_slice> slices std::vector<file_slice> slices
= files().map_block(slot, offset, size); = files().map_block(slot, offset, size);
TORRENT_ASSERT(!slices.empty()); TORRENT_ASSERT(!slices.empty());
@ -1154,7 +1154,7 @@ ret:
TORRENT_ASSERT(bytes_left >= 0); TORRENT_ASSERT(bytes_left >= 0);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int counter = 0; int counter = 0;
#endif #endif
@ -1175,7 +1175,7 @@ ret:
if (file_bytes_left == 0) continue; if (file_bytes_left == 0) continue;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(int(slices.size()) > counter); TORRENT_ASSERT(int(slices.size()) > counter);
size_type slice_size = slices[counter].size; size_type slice_size = slices[counter].size;
TORRENT_ASSERT(slice_size == file_bytes_left); TORRENT_ASSERT(slice_size == file_bytes_left);

View File

@ -321,7 +321,7 @@ namespace libtorrent
if (!p.resume_data.empty() && (p.flags & add_torrent_params::flag_override_resume_data) == 0) if (!p.resume_data.empty() && (p.flags & add_torrent_params::flag_override_resume_data) == 0)
m_need_save_resume_data = false; m_need_save_resume_data = false;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_resume_data_loaded = false; m_resume_data_loaded = false;
#endif #endif
#if TORRENT_USE_UNC_PATHS #if TORRENT_USE_UNC_PATHS
@ -490,7 +490,7 @@ namespace libtorrent
// update our torrent_info object and move the // update our torrent_info object and move the
// torrent from the old info-hash to the new one // torrent from the old info-hash to the new one
// as we replace the torrent_info object // as we replace the torrent_info object
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int num_torrents = m_ses.m_torrents.size(); int num_torrents = m_ses.m_torrents.size();
#endif #endif
// we're about to erase the session's reference to this // we're about to erase the session's reference to this
@ -599,7 +599,7 @@ namespace libtorrent
// update our torrent_info object and move the // update our torrent_info object and move the
// torrent from the old info-hash to the new one // torrent from the old info-hash to the new one
// as we replace the torrent_info object // as we replace the torrent_info object
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int num_torrents = m_ses.m_torrents.size(); int num_torrents = m_ses.m_torrents.size();
#endif #endif
@ -1549,7 +1549,7 @@ namespace libtorrent
m_ses.m_io_service.post(boost::bind(&torrent::files_checked, shared_from_this())); m_ses.m_io_service.post(boost::bind(&torrent::files_checked, shared_from_this()));
std::vector<char>().swap(m_resume_data); std::vector<char>().swap(m_resume_data);
lazy_entry().swap(m_resume_entry); lazy_entry().swap(m_resume_entry);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_resume_data_loaded = true; m_resume_data_loaded = true;
#endif #endif
return; return;
@ -1591,7 +1591,7 @@ namespace libtorrent
} }
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_resume_data_loaded = true; m_resume_data_loaded = true;
#endif #endif
@ -4832,7 +4832,7 @@ namespace libtorrent
} }
if (!c) return; if (!c) return;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
c->m_in_constructor = false; c->m_in_constructor = false;
#endif #endif
@ -4855,7 +4855,7 @@ namespace libtorrent
TORRENT_ASSERT(!web->peer_info.connection); TORRENT_ASSERT(!web->peer_info.connection);
web->peer_info.connection = c.get(); web->peer_info.connection = c.get();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
web->peer_info.in_use = true; web->peer_info.in_use = true;
#endif #endif
@ -5746,7 +5746,7 @@ namespace libtorrent
boost::intrusive_ptr<peer_connection> c(new bt_peer_connection( boost::intrusive_ptr<peer_connection> c(new bt_peer_connection(
m_ses, s, a, peerinfo, shared_from_this(), true)); m_ses, s, a, peerinfo, shared_from_this(), true));
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
c->m_in_constructor = false; c->m_in_constructor = false;
#endif #endif
@ -6127,7 +6127,7 @@ namespace libtorrent
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
p->peer_log("*** CLOSING CONNECTION \"%s\"", ec.message().c_str()); p->peer_log("*** CLOSING CONNECTION \"%s\"", ec.message().c_str());
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
std::size_t size = m_connections.size(); std::size_t size = m_connections.size();
#endif #endif
if (p->is_disconnecting()) if (p->is_disconnecting())
@ -6198,7 +6198,7 @@ namespace libtorrent
peer_connection* p = *i; peer_connection* p = *i;
++ret; ++ret;
TORRENT_ASSERT(p->associated_torrent().lock().get() == this); TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
int num_conns = m_connections.size(); int num_conns = m_connections.size();
#endif #endif
p->disconnect(ec); p->disconnect(ec);
@ -8583,7 +8583,7 @@ namespace libtorrent
void torrent::set_state(torrent_status::state_t s) void torrent::set_state(torrent_status::state_t s)
{ {
TORRENT_ASSERT(m_ses.is_network_thread()); TORRENT_ASSERT(m_ses.is_network_thread());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
if (s != torrent_status::checking_files if (s != torrent_status::checking_files
&& s != torrent_status::queued_for_checking) && s != torrent_status::queued_for_checking)
{ {

View File

@ -613,7 +613,7 @@ namespace libtorrent
error_code ec; error_code ec;
m_info_section.reset(new char[m_info_section_size]); m_info_section.reset(new char[m_info_section_size]);
memcpy(m_info_section.get(), t.m_info_section.get(), m_info_section_size); memcpy(m_info_section.get(), t.m_info_section.get(), m_info_section_size);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || !defined BOOST_NO_EXCEPTIONS #if TORRENT_USE_ASSERTS || !defined BOOST_NO_EXCEPTIONS
int ret = int ret =
#endif #endif
lazy_bdecode(m_info_section.get(), m_info_section.get() lazy_bdecode(m_info_section.get(), m_info_section.get()

View File

@ -84,7 +84,7 @@ udp_socket::udp_socket(asio::io_service& ios
#endif #endif
, m_v4_write_subscribed(false) , m_v4_write_subscribed(false)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_magic = 0x1337; m_magic = 0x1337;
m_started = false; m_started = false;
m_outstanding_when_aborted = -1; m_outstanding_when_aborted = -1;
@ -112,13 +112,13 @@ udp_socket::~udp_socket()
TORRENT_ASSERT_VAL(m_v4_outstanding == 0, m_v4_outstanding); TORRENT_ASSERT_VAL(m_v4_outstanding == 0, m_v4_outstanding);
TORRENT_ASSERT(m_magic == 0x1337); TORRENT_ASSERT(m_magic == 0x1337);
TORRENT_ASSERT(m_observers_locked == false); TORRENT_ASSERT(m_observers_locked == false);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
m_magic = 0; m_magic = 0;
#endif #endif
TORRENT_ASSERT(m_outstanding_ops == 0); TORRENT_ASSERT(m_outstanding_ops == 0);
} }
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
#define CHECK_MAGIC check_magic_ cm_(m_magic) #define CHECK_MAGIC check_magic_ cm_(m_magic)
struct check_magic_ struct check_magic_
{ {
@ -631,7 +631,7 @@ void udp_socket::close()
// we just called done, which means on_timeout // we just called done, which means on_timeout
// won't be called. Decrement the outstanding // won't be called. Decrement the outstanding
// ops counter for that // ops counter for that
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0); TORRENT_ASSERT(m_outstanding_timeout > 0);
--m_outstanding_timeout; --m_outstanding_timeout;
@ -763,7 +763,7 @@ void udp_socket::set_proxy_settings(proxy_settings const& ps)
// connect to socks5 server and open up the UDP tunnel // connect to socks5 server and open up the UDP tunnel
tcp::resolver::query q(ps.hostname, to_string(ps.port).elems); tcp::resolver::query q(ps.hostname, to_string(ps.port).elems);
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_resolve; ++m_outstanding_resolve;
#endif #endif
m_resolver.async_resolve(q, boost::bind( m_resolver.async_resolve(q, boost::bind(
@ -773,7 +773,7 @@ void udp_socket::set_proxy_settings(proxy_settings const& ps)
void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i) void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_resolve > 0); TORRENT_ASSERT(m_outstanding_resolve > 0);
--m_outstanding_resolve; --m_outstanding_resolve;
#endif #endif
@ -829,7 +829,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
// decrement if that happens // decrement if that happens
m_outstanding_ops += 2; m_outstanding_ops += 2;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_timeout; ++m_outstanding_timeout;
++m_outstanding_connect_queue; ++m_outstanding_connect_queue;
#endif #endif
@ -839,7 +839,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
void udp_socket::on_timeout() void udp_socket::on_timeout()
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0); TORRENT_ASSERT(m_outstanding_timeout > 0);
--m_outstanding_timeout; --m_outstanding_timeout;
print_backtrace(timeout_stack, sizeof(timeout_stack)); print_backtrace(timeout_stack, sizeof(timeout_stack));
@ -867,7 +867,7 @@ void udp_socket::on_timeout()
void udp_socket::on_connect(int ticket) void udp_socket::on_connect(int ticket)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_connect_queue > 0); TORRENT_ASSERT(m_outstanding_connect_queue > 0);
--m_outstanding_connect_queue; --m_outstanding_connect_queue;
#endif #endif
@ -883,7 +883,7 @@ void udp_socket::on_connect(int ticket)
if (ticket == -1) if (ticket == -1)
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0); TORRENT_ASSERT(m_outstanding_timeout > 0);
--m_outstanding_timeout; --m_outstanding_timeout;
print_backtrace(timeout_stack, sizeof(timeout_stack)); print_backtrace(timeout_stack, sizeof(timeout_stack));
@ -911,7 +911,7 @@ void udp_socket::on_connect(int ticket)
error_code ec; error_code ec;
m_socks5_sock.open(m_proxy_addr.address().is_v4()?tcp::v4():tcp::v6(), ec); m_socks5_sock.open(m_proxy_addr.address().is_v4()?tcp::v4():tcp::v6(), ec);
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_connect; ++m_outstanding_connect;
#endif #endif
m_socks5_sock.async_connect(tcp::endpoint(m_proxy_addr.address(), m_proxy_addr.port()) m_socks5_sock.async_connect(tcp::endpoint(m_proxy_addr.address(), m_proxy_addr.port())
@ -923,7 +923,7 @@ void udp_socket::on_connected(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_connected"); complete_async("udp_socket::on_connected");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_connect > 0); TORRENT_ASSERT(m_outstanding_connect > 0);
--m_outstanding_connect; --m_outstanding_connect;
#endif #endif
@ -950,7 +950,7 @@ void udp_socket::on_connected(error_code const& e)
// we just called done, which means on_timeout // we just called done, which means on_timeout
// won't be called. Decrement the outstanding // won't be called. Decrement the outstanding
// ops counter for that // ops counter for that
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0); TORRENT_ASSERT(m_outstanding_timeout > 0);
--m_outstanding_timeout; --m_outstanding_timeout;
print_backtrace(timeout_stack, sizeof(timeout_stack)); print_backtrace(timeout_stack, sizeof(timeout_stack));
@ -992,7 +992,7 @@ void udp_socket::on_connected(error_code const& e)
add_outstanding_async("udp_socket::on_handshake1"); add_outstanding_async("udp_socket::on_handshake1");
#endif #endif
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_socks; ++m_outstanding_socks;
#endif #endif
asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf) asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf)
@ -1004,7 +1004,7 @@ void udp_socket::handshake1(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake1"); complete_async("udp_socket::on_handshake1");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0); TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks; --m_outstanding_socks;
#endif #endif
@ -1029,7 +1029,7 @@ void udp_socket::handshake1(error_code const& e)
add_outstanding_async("udp_socket::on_handshake2"); add_outstanding_async("udp_socket::on_handshake2");
#endif #endif
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_socks; ++m_outstanding_socks;
#endif #endif
asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 2) asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 2)
@ -1041,7 +1041,7 @@ void udp_socket::handshake2(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake2"); complete_async("udp_socket::on_handshake2");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0); TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks; --m_outstanding_socks;
#endif #endif
@ -1103,7 +1103,7 @@ void udp_socket::handshake2(error_code const& e)
add_outstanding_async("udp_socket::on_handshake3"); add_outstanding_async("udp_socket::on_handshake3");
#endif #endif
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_socks; ++m_outstanding_socks;
#endif #endif
asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf) asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf)
@ -1123,7 +1123,7 @@ void udp_socket::handshake3(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake3"); complete_async("udp_socket::on_handshake3");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0); TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks; --m_outstanding_socks;
#endif #endif
@ -1148,7 +1148,7 @@ void udp_socket::handshake3(error_code const& e)
add_outstanding_async("udp_socket::on_handshake4"); add_outstanding_async("udp_socket::on_handshake4");
#endif #endif
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_socks; ++m_outstanding_socks;
#endif #endif
asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 2) asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 2)
@ -1160,7 +1160,7 @@ void udp_socket::handshake4(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake4"); complete_async("udp_socket::on_handshake4");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0); TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks; --m_outstanding_socks;
#endif #endif
@ -1215,7 +1215,7 @@ void udp_socket::socks_forward_udp()
add_outstanding_async("udp_socket::connect1"); add_outstanding_async("udp_socket::connect1");
#endif #endif
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_socks; ++m_outstanding_socks;
#endif #endif
asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf) asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf)
@ -1227,7 +1227,7 @@ void udp_socket::connect1(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::connect1"); complete_async("udp_socket::connect1");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0); TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks; --m_outstanding_socks;
#endif #endif
@ -1252,7 +1252,7 @@ void udp_socket::connect1(error_code const& e)
add_outstanding_async("udp_socket::connect2"); add_outstanding_async("udp_socket::connect2");
#endif #endif
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_socks; ++m_outstanding_socks;
#endif #endif
asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 10) asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 10)
@ -1264,7 +1264,7 @@ void udp_socket::connect2(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::connect2"); complete_async("udp_socket::connect2");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0); TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks; --m_outstanding_socks;
#endif #endif
@ -1324,7 +1324,7 @@ void udp_socket::connect2(error_code const& e)
add_outstanding_async("udp_socket::hung_up"); add_outstanding_async("udp_socket::hung_up");
#endif #endif
++m_outstanding_ops; ++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
++m_outstanding_socks; ++m_outstanding_socks;
#endif #endif
asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 10) asio::async_read(m_socks5_sock, asio::buffer(m_tmp_buf, 10)
@ -1336,7 +1336,7 @@ void udp_socket::hung_up(error_code const& e)
#if defined TORRENT_ASIO_DEBUGGING #if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::hung_up"); complete_async("udp_socket::hung_up");
#endif #endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0); TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks; --m_outstanding_socks;
#endif #endif

View File

@ -1695,7 +1695,7 @@ bool utp_socket_impl::send_pkt(int flags)
boost::uint8_t* ptr = NULL; boost::uint8_t* ptr = NULL;
utp_header* h = NULL; utp_header* h = NULL;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
bool stack_alloced = false; bool stack_alloced = false;
#endif #endif
@ -1719,7 +1719,7 @@ bool utp_socket_impl::send_pkt(int flags)
} }
else else
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if TORRENT_USE_ASSERTS
stack_alloced = true; stack_alloced = true;
#endif #endif
TORRENT_ASSERT(force); TORRENT_ASSERT(force);