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.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>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 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 |
| | 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 |
| | 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);
#endif
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) \
&& !TORRENT_NO_ASSERTS
#if TORRENT_USE_ASSERTS
#if TORRENT_PRODUCTION_ASSERTS
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)
#endif
#else // TORRENT_DEBUG || TORENT_RELEASE_ASSERTS && !TORRENT_NO_ASSERTS
#else // TORRENT_USE_ASSERTS
#define TORRENT_ASSERT(a) 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

View File

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

View File

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

View File

@ -354,7 +354,7 @@ private:
bool m_supports_dht_port: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
// bitfield is sent to this peer
bool m_sent_bitfield:1;

View File

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

View File

@ -57,7 +57,7 @@ POSSIBILITY OF SUCH DAMAGE.
#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 \
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 \
build, to automatically apply these defines
#endif
@ -569,6 +569,17 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
#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
#ifdef BOOST_NO_EXCEPTIONS
#define TORRENT_TRY if (true)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -123,7 +123,7 @@ namespace libtorrent
// the state of this block
enum { state_none, state_requested, state_writing, state_finished };
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
int piece_index;
#endif

View File

@ -147,7 +147,7 @@ namespace libtorrent
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);
#endif
#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
// never considered a connect candidate
bool web_seed:1;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
bool in_use:1;
#endif
};

View File

@ -144,7 +144,7 @@ namespace libtorrent
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
{ return m_connections.find(p) != m_connections.end(); }
#endif
@ -1417,7 +1417,7 @@ namespace libtorrent
// millionths of completeness)
unsigned int m_progress_ppm:20;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
public:
// set to false until we've loaded resume data
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 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
mutable pthread_t m_thread;
@ -274,7 +274,7 @@ namespace libtorrent
#endif
bool m_v4_write_subscribed:1;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
bool m_started;
int m_magic;
int m_outstanding_when_aborted;

View File

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

View File

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

View File

@ -206,7 +206,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth) {}
#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
char const* libtorrent_assert_log = "asserts.log";

View File

@ -59,7 +59,7 @@ namespace libtorrent
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
{
for (queue_t::const_iterator i = m_queue.begin()

View File

@ -109,7 +109,7 @@ namespace libtorrent
, m_supports_extensions(false)
, m_supports_dht_port(false)
, m_supports_fast(false)
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
, m_sent_bitfield(false)
, m_in_constructor(true)
, m_sent_handshake(false)
@ -134,7 +134,7 @@ namespace libtorrent
peer_log("*** bt_peer_connection");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_in_constructor = false;
#endif
#ifndef TORRENT_DISABLE_EXTENSIONS
@ -264,7 +264,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_sent_bitfield = true;
#endif
#ifdef TORRENT_VERBOSE_LOGGING
@ -278,7 +278,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_sent_bitfield = true;
#endif
#ifdef TORRENT_VERBOSE_LOGGING
@ -710,7 +710,7 @@ namespace libtorrent
INVARIANT_CHECK;
TORRENT_ASSERT(!m_sent_handshake);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_sent_handshake = true;
#endif
@ -1969,7 +1969,7 @@ namespace libtorrent
// if we are super seeding, pretend to not have any piece
// and don't send a bitfield
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_sent_bitfield = true;
#endif
@ -1996,7 +1996,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING
peer_log(" *** NOT SENDING BITFIELD");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_sent_bitfield = true;
#endif
return;
@ -2071,7 +2071,7 @@ namespace libtorrent
}
peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str());
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_sent_bitfield = true;
#endif

View File

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

View File

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

View File

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

View File

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

View File

@ -30,11 +30,12 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <libtorrent/config.hpp>
#include <libtorrent/hasher.hpp>
#include <libtorrent/kademlia/get_item.hpp>
#include <libtorrent/kademlia/node.hpp>
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && !TORRENT_NO_ASSERTS
#if TORRENT_USE_ASSERTS
#include <libtorrent/bencode.hpp>
#endif
@ -65,7 +66,7 @@ void get_item::got_data(lazy_entry const* v,
bool put_requested = m_data_callback(m_data);
if (put_requested)
{
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && !TORRENT_NO_ASSERTS
#if TORRENT_USE_ASSERTS
std::vector<char> buffer;
bencode(std::back_inserter(buffer), m_data.value());
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)
{
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;
#endif
return o;
@ -128,7 +129,7 @@ void get_item::done()
bool put_requested = m_data_callback(m_data);
if (put_requested)
{
#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) && !TORRENT_NO_ASSERTS
#if TORRENT_USE_ASSERTS
if (m_data.is_mutable())
{
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();
if (ptr == 0) return;
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;
#endif
entry e;

View File

@ -149,7 +149,7 @@ observer_ptr get_peers::new_observer(void* ptr
, udp::endpoint const& ep, node_id const& 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;
#endif
return o;
@ -175,7 +175,7 @@ observer_ptr obfuscated_get_peers::new_observer(void* ptr
if (m_obfuscated)
{
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;
#endif
return o;
@ -183,7 +183,7 @@ observer_ptr obfuscated_get_peers::new_observer(void* ptr
else
{
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;
#endif
return o;

View File

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

View File

@ -59,7 +59,7 @@ observer_ptr traversal_algorithm::new_observer(void* ptr
, udp::endpoint const& ep, node_id const& 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;
#endif
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 defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
for (int i = 100; i < m_results.size(); ++i)
m_results[i]->m_was_abandoned = true;
#endif

View File

@ -191,7 +191,7 @@ namespace libtorrent
, m_upload_only(false)
, m_snubbed(false)
, m_no_download(false)
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
, m_in_constructor(true)
, m_disconnect_started(false)
, m_initialized(false)
@ -705,7 +705,7 @@ namespace libtorrent
m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all);
if (m_have_all) m_num_pieces = t->torrent_file().num_pieces();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(!m_initialized);
m_initialized = true;
#endif
@ -761,7 +761,7 @@ namespace libtorrent
TORRENT_ASSERT(m_disconnect_started);
TORRENT_ASSERT(m_ses.is_network_thread());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_in_use = 0;
#endif
@ -792,7 +792,7 @@ namespace libtorrent
// TORRENT_ASSERT(!m_ses.has_peer(this));
TORRENT_ASSERT(m_request_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()
, end(m_ses.m_torrents.end()); i != end; ++i)
TORRENT_ASSERT(!i->second->has_peer(this));
@ -900,7 +900,7 @@ namespace libtorrent
peer_log("==> HAVE [ piece: %d ]", index);
#endif
write_have(index);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t);
#endif
@ -2115,7 +2115,7 @@ namespace libtorrent
m_outstanding_bytes -= bytes;
if (m_outstanding_bytes < 0) m_outstanding_bytes = 0;
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());
m_received_in_piece += bytes;
#endif
@ -2133,7 +2133,7 @@ namespace libtorrent
#if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_DEBUG
check_invariant();
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
buffer::const_interval recv_buffer = receive_buffer();
int recv_pos = recv_buffer.end - recv_buffer.begin;
TORRENT_ASSERT(recv_pos >= 9);
@ -2296,7 +2296,7 @@ namespace libtorrent
{
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);
m_received_in_piece = 0;
#endif
@ -2338,7 +2338,7 @@ namespace libtorrent
// just ignore it
if (t->is_seed())
{
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_received_in_piece == p.length);
m_received_in_piece = 0;
#endif
@ -2372,7 +2372,7 @@ namespace libtorrent
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
peer_log("*** The block we just got was not in the request queue ***");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT_VAL(m_received_in_piece == p.length, m_received_in_piece);
m_received_in_piece = 0;
#endif
@ -2380,7 +2380,7 @@ namespace libtorrent
return;
}
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
pending_block pending_b = *b;
#endif
@ -2433,7 +2433,7 @@ namespace libtorrent
b = m_download_queue.begin() + block_index;
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);
m_received_in_piece = 0;
#endif
@ -2529,7 +2529,7 @@ namespace libtorrent
t->check_invariant();
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
piece_picker::downloading_piece pi;
picker.piece_info(p.piece, pi);
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()
, m_request_queue.end(), has_block(block));
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();
TORRENT_ASSERT(t);
TORRENT_ASSERT(t->has_picker());
@ -3470,7 +3470,7 @@ namespace libtorrent
// 2 protocol error (client sent something invalid)
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;
#endif
@ -5331,7 +5331,7 @@ namespace libtorrent
TORRENT_ASSERT(m_recv_pos <= int(m_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_protocol_dl = m_statistics.last_protocol_downloaded();
#endif
@ -5339,7 +5339,7 @@ namespace libtorrent
INVARIANT_CHECK;
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_protocol_downloaded() - cur_protocol_dl >= 0);
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)
{
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
// keep the connection alive until the
// exit invariant check is run
@ -5713,12 +5713,12 @@ namespace libtorrent
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_protocol_ul = m_statistics.last_protocol_uploaded();
#endif
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_protocol_uploaded() - cur_protocol_ul >= 0);
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/random.hpp"
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
#include "libtorrent/peer_connection.hpp"
#include "libtorrent/torrent.hpp"
#include "libtorrent/policy.hpp" // for policy::peer
@ -206,7 +206,7 @@ namespace libtorrent
#ifdef TORRENT_USE_VALGRIND
VALGRIND_CHECK_VALUE_IS_DEFINED(ret.info[i].peer);
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
ret.info[i].piece_index = piece;
#endif
}
@ -1061,7 +1061,7 @@ namespace libtorrent
int index = 0;
bool updated = false;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
bool seed_broken = false;
#endif
for (bitfield::const_iterator i = bitmask.begin()
@ -1084,7 +1084,7 @@ namespace libtorrent
// piece anymore. we need to break up one of the seed
// counters into actual peer counters on the pieces
break_one_seed();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
seed_broken = true;
#endif
}

View File

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

View File

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

View File

@ -277,7 +277,7 @@ namespace libtorrent
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 size = 0;
@ -1127,7 +1127,7 @@ ret:
int size = bufs_size(bufs, num_bufs);
TORRENT_ASSERT(size > 0);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
std::vector<file_slice> slices
= files().map_block(slot, offset, size);
TORRENT_ASSERT(!slices.empty());
@ -1154,7 +1154,7 @@ ret:
TORRENT_ASSERT(bytes_left >= 0);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
int counter = 0;
#endif
@ -1175,7 +1175,7 @@ ret:
if (file_bytes_left == 0) continue;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(int(slices.size()) > counter);
size_type slice_size = slices[counter].size;
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)
m_need_save_resume_data = false;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_resume_data_loaded = false;
#endif
#if TORRENT_USE_UNC_PATHS
@ -490,7 +490,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
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
int num_torrents = m_ses.m_torrents.size();
#endif
// 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
// torrent from the old info-hash to the new one
// 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();
#endif
@ -1549,7 +1549,7 @@ namespace libtorrent
m_ses.m_io_service.post(boost::bind(&torrent::files_checked, shared_from_this()));
std::vector<char>().swap(m_resume_data);
lazy_entry().swap(m_resume_entry);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_resume_data_loaded = true;
#endif
return;
@ -1591,7 +1591,7 @@ namespace libtorrent
}
}
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_resume_data_loaded = true;
#endif
@ -4832,7 +4832,7 @@ namespace libtorrent
}
if (!c) return;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
c->m_in_constructor = false;
#endif
@ -4855,7 +4855,7 @@ namespace libtorrent
TORRENT_ASSERT(!web->peer_info.connection);
web->peer_info.connection = c.get();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
web->peer_info.in_use = true;
#endif
@ -5746,7 +5746,7 @@ namespace libtorrent
boost::intrusive_ptr<peer_connection> c(new bt_peer_connection(
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;
#endif
@ -6127,7 +6127,7 @@ namespace libtorrent
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
p->peer_log("*** CLOSING CONNECTION \"%s\"", ec.message().c_str());
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
std::size_t size = m_connections.size();
#endif
if (p->is_disconnecting())
@ -6198,7 +6198,7 @@ namespace libtorrent
peer_connection* p = *i;
++ret;
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();
#endif
p->disconnect(ec);
@ -8583,7 +8583,7 @@ namespace libtorrent
void torrent::set_state(torrent_status::state_t s)
{
TORRENT_ASSERT(m_ses.is_network_thread());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
if (s != torrent_status::checking_files
&& s != torrent_status::queued_for_checking)
{

View File

@ -613,7 +613,7 @@ namespace libtorrent
error_code ec;
m_info_section.reset(new char[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 =
#endif
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
, m_v4_write_subscribed(false)
{
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_magic = 0x1337;
m_started = false;
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(m_magic == 0x1337);
TORRENT_ASSERT(m_observers_locked == false);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
m_magic = 0;
#endif
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)
struct check_magic_
{
@ -631,7 +631,7 @@ void udp_socket::close()
// we just called done, which means on_timeout
// won't be called. Decrement the outstanding
// ops counter for that
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0);
--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
tcp::resolver::query q(ps.hostname, to_string(ps.port).elems);
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_resolve;
#endif
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)
{
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_resolve > 0);
--m_outstanding_resolve;
#endif
@ -829,7 +829,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
// decrement if that happens
m_outstanding_ops += 2;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_timeout;
++m_outstanding_connect_queue;
#endif
@ -839,7 +839,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
void udp_socket::on_timeout()
{
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0);
--m_outstanding_timeout;
print_backtrace(timeout_stack, sizeof(timeout_stack));
@ -867,7 +867,7 @@ void udp_socket::on_timeout()
void udp_socket::on_connect(int ticket)
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_connect_queue > 0);
--m_outstanding_connect_queue;
#endif
@ -883,7 +883,7 @@ void udp_socket::on_connect(int ticket)
if (ticket == -1)
{
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0);
--m_outstanding_timeout;
print_backtrace(timeout_stack, sizeof(timeout_stack));
@ -911,7 +911,7 @@ void udp_socket::on_connect(int ticket)
error_code ec;
m_socks5_sock.open(m_proxy_addr.address().is_v4()?tcp::v4():tcp::v6(), ec);
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_connect;
#endif
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
complete_async("udp_socket::on_connected");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_connect > 0);
--m_outstanding_connect;
#endif
@ -950,7 +950,7 @@ void udp_socket::on_connected(error_code const& e)
// we just called done, which means on_timeout
// won't be called. Decrement the outstanding
// ops counter for that
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0);
--m_outstanding_timeout;
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");
#endif
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
#endif
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
complete_async("udp_socket::on_handshake1");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
#endif
@ -1029,7 +1029,7 @@ void udp_socket::handshake1(error_code const& e)
add_outstanding_async("udp_socket::on_handshake2");
#endif
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
#endif
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
complete_async("udp_socket::on_handshake2");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
#endif
@ -1103,7 +1103,7 @@ void udp_socket::handshake2(error_code const& e)
add_outstanding_async("udp_socket::on_handshake3");
#endif
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
#endif
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
complete_async("udp_socket::on_handshake3");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
#endif
@ -1148,7 +1148,7 @@ void udp_socket::handshake3(error_code const& e)
add_outstanding_async("udp_socket::on_handshake4");
#endif
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
#endif
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
complete_async("udp_socket::on_handshake4");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
#endif
@ -1215,7 +1215,7 @@ void udp_socket::socks_forward_udp()
add_outstanding_async("udp_socket::connect1");
#endif
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
#endif
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
complete_async("udp_socket::connect1");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
#endif
@ -1252,7 +1252,7 @@ void udp_socket::connect1(error_code const& e)
add_outstanding_async("udp_socket::connect2");
#endif
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
#endif
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
complete_async("udp_socket::connect2");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
#endif
@ -1324,7 +1324,7 @@ void udp_socket::connect2(error_code const& e)
add_outstanding_async("udp_socket::hung_up");
#endif
++m_outstanding_ops;
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
#endif
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
complete_async("udp_socket::hung_up");
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
#endif

View File

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