fixed compiler flags in pkg-config file and made header files not depend on the NDEBUG define

This commit is contained in:
Arvid Norberg 2008-11-29 21:33:21 +00:00
parent d1a2b774e6
commit 09b3a865ef
50 changed files with 227 additions and 217 deletions

View File

@ -372,6 +372,7 @@ local usage-requirements =
<include>./include/libtorrent
<zlib>shipped:<include>./zlib
<variant>release:<define>NDEBUG
<variant>debug:<define>TORRENT_DEBUG
<define>_FILE_OFFSET_BITS=64
<define>BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
<conditional>@linking

View File

@ -50,7 +50,7 @@ if platform.system() == 'Windows':
source_list = os.listdir(os.path.join(os.path.dirname(__file__), "src"))
source_list = [os.path.join("src", s) for s in source_list if s.endswith(".cpp")]
extra_cmd = '@COMPILETIME_OPTIONS@ @CPPFLAGS@'
extra_cmd = '@COMPILETIME_OPTIONS@ @CPPFLAGS@ @LIBS@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @SSL_LIBS@ @BOOST_SYSTEM_LIB@ @SSL_LDFLAGS@ @SSL_CXXFLAGS@'
setup( name='python-libtorrent',
version='@PACKAGE_VERSION@',

View File

@ -410,7 +410,7 @@ esac
dnl Set some defines if we are building a shared library
if [[ "x$enable_shared" == "xyes" ]]; then
AC_DEFINE(TORRENT_BUILDING_SHARED,,[Make sure the functions and classes are exported.])
AC_DEFINE(TORRENT_LINKING_SHARED,,[Make sure the functions and classes are exported.])
COMPILETIME_OPTIONS+="-DTORRENT_LINKING_SHARED "
fi
dnl want some debugging symbols with that?
@ -420,19 +420,23 @@ AC_ARG_ENABLE(
[case "$enableval" in
no)
AC_DEFINE(NDEBUG,,[Define to disable debugging])
DEBUGFLAGS=""
COMPILETIME_OPTIONS+="-DNDEBUG "
DEBUGFLAGS="-Os"
# COMPILETIME_OPTIONS+="-DNDEBUG "
;;
yes)
DEBUGFLAGS="-g"
COMPILETIME_OPTIONS+="-DLT_DEBUG "
COMPILETIME_OPTIONS+="-DTORRENT_DEBUG "
AC_DEFINE(TORRENT_DEBUG,,[Define to enable libtorrent debug build])
;;
*)
DEBUGFLAGS="$enableval"
AC_MSG_RESULT()
AC_MSG_ERROR([Unknown --enable-debug option "$enableval". Use either "yes" or "no".])
;;
esac],
[DEBUGFLAGS=""
AC_DEFINE(NDEBUG,,[Define to disable debugging])]
[DEBUGFLAGS="-Os"
AC_DEFINE(NDEBUG,,[Define to disable debugging])
# COMPILETIME_OPTIONS+="-DNDEBUG "
]
)
AC_SUBST(DEBUGFLAGS)

View File

@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
std::string demangle(char const* name);
#endif
#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && !defined(NDEBUG)
#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && defined TORRENT_DEBUG
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function);
#define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__); } while (false)

View File

@ -110,7 +110,7 @@ namespace libtorrent
// the size of each allocation that is chained in the send buffer
enum { send_buffer_size = 200 };
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
friend class ::libtorrent::peer_connection;
#endif
friend struct checker_impl;
@ -132,7 +132,7 @@ namespace libtorrent
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(
torrent*, void*)> ext);
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool has_peer(peer_connection const* p) const
{
return std::find_if(m_connections.begin(), m_connections.end()
@ -580,7 +580,7 @@ namespace libtorrent
// connect to a peer next time second_tick is called.
// This implements a round robin.
int m_next_connect_torrent;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif

View File

@ -157,7 +157,7 @@ struct bandwidth_manager
m_history_timer.cancel(ec);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool is_queued(PeerConnection const* peer) const
{
mutex_t::scoped_lock l(m_mutex);
@ -223,7 +223,7 @@ struct bandwidth_manager
if (!m_queue.empty()) hand_out_bandwidth(l);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const
{
int current_quota = 0;

View File

@ -238,7 +238,7 @@ namespace libtorrent
if (in == end)
{
err = true;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
@ -257,7 +257,7 @@ namespace libtorrent
++in; // 'e'
ret = entry(entry::int_t);
ret.integer() = boost::lexical_cast<entry::integer_type>(val);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
} break;
@ -275,7 +275,7 @@ namespace libtorrent
bdecode_recursive(in, end, e, err, depth + 1);
if (err)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
@ -283,13 +283,13 @@ namespace libtorrent
if (in == end)
{
err = true;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
}
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
TORRENT_ASSERT(*in == 'e');
@ -308,7 +308,7 @@ namespace libtorrent
bdecode_recursive(in, end, key, err, depth + 1);
if (err || key.type() != entry::string_t)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
@ -317,7 +317,7 @@ namespace libtorrent
bdecode_recursive(in, end, e, err, depth + 1);
if (err)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
@ -325,13 +325,13 @@ namespace libtorrent
if (in == end)
{
err = true;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
}
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
TORRENT_ASSERT(*in == 'e');
@ -346,7 +346,7 @@ namespace libtorrent
std::string len_s = read_until(in, end, ':', err);
if (err)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
@ -358,7 +358,7 @@ namespace libtorrent
read_string(in, end, len, ret.string(), err);
if (err)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
@ -367,12 +367,12 @@ namespace libtorrent
else
{
err = true;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
return;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
ret.m_type_queried = false;
#endif
}
@ -391,7 +391,9 @@ namespace libtorrent
entry e;
bool err = false;
detail::bdecode_recursive(start, end, e, err, 0);
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(e.m_type_queried == false);
#endif
if (err) return entry();
return e;
}
@ -411,3 +413,4 @@ namespace libtorrent
}
#endif // TORRENT_BENCODE_HPP_INCLUDED

View File

@ -233,7 +233,7 @@ namespace libtorrent
void on_connected();
void on_metadata();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
ptime m_last_choke;
#endif
@ -407,7 +407,7 @@ private:
boost::scoped_ptr<sha1_hash> m_sync_hash;
#endif // #ifndef TORRENT_DISABLE_ENCRYPTION
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// this is set to true when the client's
// bitfield is sent to this peer
bool m_sent_bitfield;

View File

@ -65,7 +65,7 @@ public:
void close();
int size() const { return m_queue.size(); }
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif
@ -101,7 +101,7 @@ private:
typedef boost::recursive_mutex mutex_t;
mutable mutex_t m_mutex;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool m_in_timeout_function;
#endif
#ifdef TORRENT_CONNECTION_LOGGING

View File

@ -191,14 +191,14 @@ namespace libtorrent
void operator()();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool is_disk_buffer(char* buffer) const;
#endif
char* allocate_buffer();
void free_buffer(char* buf);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif

View File

@ -206,7 +206,7 @@ namespace libtorrent
};
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
public:
// in debug mode this is set to false by bdecode
// to indicate that the program has not yet queried
@ -226,7 +226,7 @@ namespace libtorrent
inline entry::data_type entry::type() const
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
return m_type;
@ -245,7 +245,7 @@ namespace libtorrent
if (m_type == undefined_t) construct(int_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != int_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == int_t);
@ -256,7 +256,7 @@ namespace libtorrent
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != int_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == int_t);
@ -268,7 +268,7 @@ namespace libtorrent
if (m_type == undefined_t) construct(string_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != string_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == string_t);
@ -279,7 +279,7 @@ namespace libtorrent
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != string_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == string_t);
@ -291,7 +291,7 @@ namespace libtorrent
if (m_type == undefined_t) construct(list_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != list_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == list_t);
@ -302,7 +302,7 @@ namespace libtorrent
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != list_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == list_t);
@ -314,7 +314,7 @@ namespace libtorrent
if (m_type == undefined_t) construct(dictionary_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != dictionary_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == dictionary_t);
@ -325,7 +325,7 @@ namespace libtorrent
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != dictionary_t) throw type_error("invalid type requested from entry");
#elif !defined NDEBUG
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == dictionary_t);
@ -335,3 +335,4 @@ namespace libtorrent
}
#endif // TORRENT_ENTRY_HPP_INCLUDED

View File

@ -111,7 +111,7 @@ namespace libtorrent
#else
int m_fd;
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int m_open_mode;
#endif

View File

@ -66,7 +66,7 @@ namespace libtorrent
}
}
#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#define INVARIANT_CHECK \
invariant_checker const& _invariant_check = make_invariant_checker(*this); \
(void)_invariant_check; \

View File

@ -150,7 +150,7 @@ public:
{
observer_ptr o(new (m_rpc.allocator().malloc()) announce_observer(
m_rpc.allocator(), m_info_hash, m_listen_port, r.write_token));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
o->m_in_constructor = false;
#endif
m_rpc.invoke(messages::announce_peer, r.addr, o);

View File

@ -57,7 +57,7 @@ struct observer : boost::noncopyable
, pool_allocator(p)
, m_refs(0)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_in_constructor = true;
#endif
}
@ -86,7 +86,7 @@ struct observer : boost::noncopyable
udp::endpoint target_addr;
ptime sent;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool m_in_constructor;
#endif
private:

View File

@ -92,7 +92,7 @@ public:
void reply(msg& m);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
size_t allocation_size() const;
void check_invariant() const;
#endif

View File

@ -399,7 +399,7 @@ namespace libtorrent
void assign_bandwidth(int channel, int amount);
void expire_bandwidth(int channel, int amount);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
ptime m_last_choke;
#endif
@ -461,7 +461,7 @@ namespace libtorrent
bool packet_finished() const
{ return m_packet_size <= m_recv_pos; }
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool piece_failed;
#endif
@ -569,7 +569,7 @@ namespace libtorrent
char m_country[2];
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
boost::intrusive_ptr<peer_connection> self()
{
TORRENT_ASSERT(!m_in_constructor);
@ -877,7 +877,7 @@ namespace libtorrent
// pick any pieces from this peer
bool m_no_download:1;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
public:
bool m_in_constructor:1;
bool m_disconnect_started:1;

View File

@ -308,14 +308,14 @@ namespace libtorrent
int num_have() const { return m_num_have; }
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// used in debug mode
void verify_priority(int start, int end, int prio) const;
void check_invariant(const torrent* t = 0) const;
void verify_pick(std::vector<piece_block> const& picked
, bitfield const& bits) const;
#endif
#if defined TORRENT_PICKER_LOG || !defined NDEBUG
#if defined TORRENT_PICKER_LOG || defined TORRENT_DEBUG
void print_pieces() const;
#endif

View File

@ -110,7 +110,7 @@ namespace libtorrent
void ip_filter_updated();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool has_connection(const peer_connection* p);
void check_invariant() const;
@ -156,7 +156,7 @@ namespace libtorrent
peer_connection* connection;
#ifndef TORRENT_DISABLE_GEO_IP
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// only used in debug mode to assert that
// the first entry in the AS pair keeps the same
boost::uint16_t inet_as_num;

View File

@ -83,7 +83,7 @@ namespace libtorrent
// this is used to create linker errors when trying to link to
// a library with a conflicting build configuration than the application
#ifdef NDEBUG
#ifdef TORRENT_DEBUG
#define G _release
#else
#define G _debug

View File

@ -97,7 +97,7 @@ namespace libtorrent
private:
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const
{
int sum = 0;

View File

@ -298,7 +298,7 @@ namespace libtorrent
bool compact_allocation() const
{ return m_storage_mode == storage_mode_compact; }
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::string name() const { return m_info->name(); }
#endif
@ -333,7 +333,7 @@ namespace libtorrent
int move_storage_impl(fs::path const& save_path);
int allocate_slot_for_piece(int piece_index);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#ifdef TORRENT_STORAGE_DEBUG
void debug_log() const;

View File

@ -282,7 +282,7 @@ namespace libtorrent
if (performace_counter_frequency.QuadPart == 0)
QueryPerformanceFrequency(&performace_counter_frequency);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// make sure we don't overflow
boost::int64_t ret = (pc * 1000 / performace_counter_frequency.QuadPart) * 1000;
TORRENT_ASSERT((pc >= 0 && pc >= ret) || (pc < 0 && pc < ret));
@ -295,7 +295,7 @@ namespace libtorrent
static LARGE_INTEGER performace_counter_frequency = {0,0};
if (performace_counter_frequency.QuadPart == 0)
QueryPerformanceFrequency(&performace_counter_frequency);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// make sure we don't overflow
boost::int64_t ret = (ms / 1000) * performace_counter_frequency.QuadPart / 1000;
TORRENT_ASSERT((ms >= 0 && ms <= ret)

View File

@ -149,7 +149,7 @@ namespace libtorrent
, void* userdata);
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool has_peer(peer_connection* p) const
{ return m_connections.find(p) != m_connections.end(); }
#endif
@ -437,7 +437,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount(index);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -453,7 +453,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount(bits);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -468,7 +468,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount_all();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -483,7 +483,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->dec_refcount(index);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -603,7 +603,7 @@ namespace libtorrent
#endif
// DEBUG
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif
@ -723,11 +723,11 @@ namespace libtorrent
// the object.
piece_manager* m_storage;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
public:
#endif
std::set<peer_connection*> m_connections;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
private:
#endif
@ -877,7 +877,7 @@ namespace libtorrent
int m_complete;
int m_incomplete;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// this is the amount downloaded when this torrent
// is started. i.e.
// total_done - m_initial_done <= total_payload_download

View File

@ -491,7 +491,7 @@ namespace libtorrent
: m_torrent(t)
{}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif

View File

@ -65,7 +65,7 @@ namespace libtorrent
void set_proxy_settings(proxy_settings const& ps);
proxy_settings const& get_proxy_settings() { return m_proxy_settings; }
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
~udp_socket() { m_magic = 0; }
#endif
@ -109,7 +109,7 @@ namespace libtorrent
char m_tmp_buf[100];
bool m_tunnel_packets;
udp::endpoint m_proxy_addr;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int m_magic;
#endif
};

View File

@ -180,12 +180,12 @@ private:
, supports_specific_external(true)
, disabled(false)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
magic = 1337;
#endif
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
~rootdevice()
{
TORRENT_ASSERT(magic == 1337);
@ -220,7 +220,7 @@ private:
mutable boost::shared_ptr<http_connection> upnp_connection;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int magic;
#endif
void close() const

View File

@ -128,7 +128,7 @@ namespace libtorrent
void write_reject_request(peer_request const&) {}
void write_allow_fast(int) {}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif

View File

@ -12,5 +12,6 @@ Name: libtorrent-rasterbar
Description: Bittorrent library.
Version: @VERSION@
Libs: -L${libdir} -ltorrent-rasterbar
Libs.private: @LIBS@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @SSL_LIBS@ @BOOST_SYSTEM_LIB@
Cflags: -I${includedir} -I${includedir}/libtorrent @COMPILETIME_OPTIONS@ @CPPFLAGS@
Libs.private: @LIBS@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @SSL_LIBS@ @BOOST_SYSTEM_LIB@ @SSL_LDFLAGS@
Cflags: -I${includedir} -I${includedir}/libtorrent @COMPILETIME_OPTIONS@ @CPPFLAGS@ @SSL_CXXFLAGS@

View File

@ -60,7 +60,7 @@ std::string demangle(char const* name)
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
#include <stdlib.h>
#include <stdio.h>

View File

@ -107,7 +107,7 @@ namespace libtorrent
, m_sync_bytes_read(0)
, m_enc_send_buffer(0, 0)
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_sent_bitfield(false)
, m_in_constructor(true)
, m_sent_handshake(false)
@ -117,7 +117,7 @@ namespace libtorrent
(*m_logger) << "*** bt_peer_connection\n";
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_in_constructor = false;
#endif
}
@ -140,7 +140,7 @@ namespace libtorrent
, m_sync_bytes_read(0)
, m_enc_send_buffer(0, 0)
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_sent_bitfield(false)
, m_in_constructor(true)
, m_sent_handshake(false)
@ -164,7 +164,7 @@ namespace libtorrent
m_bandwidth_limit[upload_channel].assign(80);
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_in_constructor = false;
#endif
}
@ -278,7 +278,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_sent_bitfield = true;
#endif
#ifdef TORRENT_VERBOSE_LOGGING
@ -293,7 +293,7 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_sent_bitfield = true;
#endif
#ifdef TORRENT_VERBOSE_LOGGING
@ -695,7 +695,7 @@ namespace libtorrent
INVARIANT_CHECK;
TORRENT_ASSERT(!m_sent_handshake);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_sent_handshake = true;
#endif
@ -1373,13 +1373,13 @@ namespace libtorrent
TORRENT_ASSERT(m_message_handler[packet_type] != 0);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
size_type cur_payload_dl = m_statistics.last_payload_downloaded();
size_type cur_protocol_dl = m_statistics.last_protocol_downloaded();
#endif
// call the correct handler for this packet type
(this->*m_message_handler[packet_type])(received);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
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 +
@ -1470,7 +1470,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " *** NOT SENDING BITFIELD\n";
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_sent_bitfield = true;
#endif
return;
@ -1539,7 +1539,7 @@ namespace libtorrent
bitfield_string << "\n";
(*m_logger) << bitfield_string.str();
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_sent_bitfield = true;
#endif
@ -2645,7 +2645,7 @@ namespace libtorrent
disconnect("torrent removed", 1);
return;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
size_type cur_payload_dl = m_statistics.last_payload_downloaded();
size_type cur_protocol_dl = m_statistics.last_protocol_downloaded();
#endif
@ -2654,7 +2654,7 @@ namespace libtorrent
m_state = read_packet_size;
reset_recv_buffer(5);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
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 +
@ -2717,7 +2717,7 @@ namespace libtorrent
m_statistics.sent_bytes(amount_payload, bytes_transferred - amount_payload);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void bt_peer_connection::check_invariant() const
{
#ifndef TORRENT_DISABLE_ENCRYPTION

View File

@ -44,7 +44,7 @@ namespace libtorrent
, m_half_open_limit(0)
, m_abort(false)
, m_timer(ios)
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_in_timeout_function(false)
#endif
{
@ -141,7 +141,7 @@ namespace libtorrent
int connection_queue::limit() const
{ return m_half_open_limit; }
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void connection_queue::check_invariant() const
{
@ -213,7 +213,7 @@ namespace libtorrent
}
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
struct function_guard
{
function_guard(bool& v): val(v) { TORRENT_ASSERT(!val); val = true; }
@ -228,7 +228,7 @@ namespace libtorrent
mutex_t::scoped_lock l(m_mutex);
INVARIANT_CHECK;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
function_guard guard_(m_in_timeout_function);
#endif

View File

@ -362,7 +362,7 @@ namespace libtorrent
}
TORRENT_ASSERT(buffer_size == 0);
// std::cerr << " flushing p: " << p.piece << " cached_blocks: " << m_cache_stats.cache_size << std::endl;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (int i = 0; i < blocks_in_piece; ++i)
TORRENT_ASSERT(p.blocks[i] == 0);
#endif
@ -504,7 +504,7 @@ namespace libtorrent
return ret;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void disk_io_thread::check_invariant() const
{
int cached_write_blocks = 0;
@ -693,7 +693,7 @@ namespace libtorrent
m_signal.notify_all();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool disk_io_thread::is_disk_buffer(char* buffer) const
{
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
@ -741,7 +741,7 @@ namespace libtorrent
j.error = ec;
j.error_file = j.storage->error_file();
j.storage->clear_error();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::cout << "ERROR: '" << j.str << "' " << j.error_file << std::endl;
#endif
return true;

View File

@ -148,7 +148,7 @@ namespace libtorrent
entry::entry()
: m_type(undefined_t)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -157,7 +157,7 @@ namespace libtorrent
: m_type(undefined_t)
{
construct(t);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -166,7 +166,7 @@ namespace libtorrent
: m_type(undefined_t)
{
copy(e);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = e.m_type_queried;
#endif
}
@ -174,7 +174,7 @@ namespace libtorrent
entry::entry(dictionary_type const& v)
: m_type(undefined_t)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
new(data) dictionary_type(v);
@ -184,7 +184,7 @@ namespace libtorrent
entry::entry(string_type const& v)
: m_type(undefined_t)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
new(data) string_type(v);
@ -194,7 +194,7 @@ namespace libtorrent
entry::entry(list_type const& v)
: m_type(undefined_t)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
new(data) list_type(v);
@ -204,7 +204,7 @@ namespace libtorrent
entry::entry(integer_type const& v)
: m_type(undefined_t)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
new(data) integer_type(v);
@ -216,7 +216,7 @@ namespace libtorrent
destruct();
new(data) dictionary_type(v);
m_type = dictionary_t;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -226,7 +226,7 @@ namespace libtorrent
destruct();
new(data) string_type(v);
m_type = string_t;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -236,7 +236,7 @@ namespace libtorrent
destruct();
new(data) list_type(v);
m_type = list_t;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -246,7 +246,7 @@ namespace libtorrent
destruct();
new(data) integer_type(v);
m_type = int_t;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -291,7 +291,7 @@ namespace libtorrent
TORRENT_ASSERT(t == undefined_t);
}
m_type = t;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -316,7 +316,7 @@ namespace libtorrent
TORRENT_ASSERT(e.type() == undefined_t);
}
m_type = e.type();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
}
@ -342,7 +342,7 @@ namespace libtorrent
break;
}
m_type = undefined_t;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_type_queried = false;
#endif
}

View File

@ -110,7 +110,7 @@ namespace libtorrent
#else
: m_fd(-1)
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_open_mode(0)
#endif
{}
@ -121,7 +121,7 @@ namespace libtorrent
#else
: m_fd(-1)
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_open_mode(0)
#endif
{
@ -182,7 +182,7 @@ namespace libtorrent
return false;
}
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_open_mode = mode;
#endif
TORRENT_ASSERT(is_open());
@ -209,7 +209,7 @@ namespace libtorrent
::close(m_fd);
m_fd = -1;
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_open_mode = 0;
#endif
}

View File

@ -88,7 +88,7 @@ void closest_nodes::invoke(node_id const& id, udp::endpoint addr)
{
TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(closest_nodes_observer));
observer_ptr o(new (m_node.m_rpc.allocator().malloc()) closest_nodes_observer(this, id, m_target));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
o->m_in_constructor = false;
#endif
m_node.m_rpc.invoke(messages::find_node, addr, o);

View File

@ -101,7 +101,7 @@ void find_data::invoke(node_id const& id, udp::endpoint addr)
TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(find_data_observer));
observer_ptr o(new (m_node.m_rpc.allocator().malloc()) find_data_observer(this, id, m_target));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
o->m_in_constructor = false;
#endif
m_node.m_rpc.invoke(messages::get_peers, addr, o);

View File

@ -273,7 +273,7 @@ namespace
TORRENT_LOG(node) << " distance: " << (160 - distance_exp(ih, i->id));
#endif
observer_ptr o(new (rpc.allocator().malloc()) get_peers_observer(ih, listen_port, rpc, f));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
o->m_in_constructor = false;
#endif
rpc.invoke(messages::get_peers, udp::endpoint(i->addr, i->port), o);
@ -295,7 +295,7 @@ void node_impl::add_node(udp::endpoint node)
// ping the node, and if we get a reply, it
// will be added to the routing table
observer_ptr o(new (m_rpc.allocator().malloc()) null_observer(m_rpc.allocator()));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
o->m_in_constructor = false;
#endif
m_rpc.invoke(messages::ping, node, o);

View File

@ -105,7 +105,7 @@ void refresh::invoke(node_id const& nid, udp::endpoint addr)
TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(refresh_observer));
observer_ptr o(new (m_node.m_rpc.allocator().malloc()) refresh_observer(
this, nid, m_target));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
o->m_in_constructor = false;
#endif
@ -161,7 +161,7 @@ void refresh::invoke_pings_or_finish(bool prevent_request)
TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(ping_observer));
observer_ptr o(new (m_node.m_rpc.allocator().malloc()) ping_observer(
this, node.id));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
o->m_in_constructor = false;
#endif
m_node.m_rpc.invoke(messages::ping, node.addr, o);

View File

@ -136,7 +136,7 @@ rpc_manager::~rpc_manager()
}
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
size_t rpc_manager::allocation_size() const
{
size_t s = sizeof(mpl::deref<max_observer_type_iter::base>::type);
@ -410,7 +410,7 @@ void rpc_manager::invoke(int message_id, udp::endpoint target_addr
m.id = m_our_id;
m.addr = target_addr;
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int potential_new_id = m_next_transaction_id;
#endif
try

View File

@ -69,7 +69,7 @@ namespace libtorrent
, tcp::endpoint const& endp
, policy::peer* peerinfo)
:
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_last_choke(time_now() - hours(1))
,
#endif
@ -131,7 +131,7 @@ namespace libtorrent
, m_snubbed(false)
, m_bitfield_received(false)
, m_no_download(false)
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_in_constructor(true)
, m_disconnect_started(false)
, m_initialized(false)
@ -161,7 +161,7 @@ namespace libtorrent
+ boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port());
(*m_logger) << "*** OUTGOING CONNECTION\n";
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
piece_failed = false;
#endif
#ifndef TORRENT_DISABLE_GEO_IP
@ -178,7 +178,7 @@ namespace libtorrent
, tcp::endpoint const& endp
, policy::peer* peerinfo)
:
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_last_choke(time_now() - hours(1))
,
#endif
@ -239,7 +239,7 @@ namespace libtorrent
, m_snubbed(false)
, m_bitfield_received(false)
, m_no_download(false)
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_in_constructor(true)
, m_disconnect_started(false)
, m_initialized(false)
@ -274,7 +274,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_GEO_IP
m_inet_as_name = m_ses.as_name_for_ip(m_remote.address());
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
piece_failed = false;
#endif
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
@ -515,7 +515,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();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_initialized = true;
#endif
// now that we have a piece_picker,
@ -579,7 +579,7 @@ namespace libtorrent
}
#endif
TORRENT_ASSERT(!m_ses.has_peer(this));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
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));
@ -681,7 +681,7 @@ namespace libtorrent
<< " ==> HAVE [ piece: " << index << "]\n";
#endif
write_have(index);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t);
TORRENT_ASSERT(t->have_piece(index));
@ -1548,7 +1548,7 @@ namespace libtorrent
m_last_piece = time_now();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
struct check_postcondition
{
check_postcondition(boost::shared_ptr<torrent> const& t_
@ -1629,7 +1629,7 @@ namespace libtorrent
#endif
if (is_disconnecting()) return;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
check_postcondition post_checker_(t);
#if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
t->check_invariant();
@ -1710,7 +1710,7 @@ namespace libtorrent
send_block_requests();
return;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
pending_block pending_b = *b;
#endif
@ -1808,7 +1808,7 @@ namespace libtorrent
TORRENT_ASSERT(picker.num_peers(block_finished) == 0);
#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS \
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS \
&& defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
t->check_invariant();
#endif
@ -1870,7 +1870,7 @@ namespace libtorrent
// did we just finish the piece?
if (picker.is_piece_finished(p.piece))
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
check_postcondition post_checker2_(t, false);
#endif
t->async_verify_piece(p.piece, bind(&torrent::piece_finished, t
@ -2235,7 +2235,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " ==> CHOKE\n";
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_last_choke = time_now();
#endif
m_num_invalid_requests = 0;
@ -2448,7 +2448,7 @@ namespace libtorrent
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_disconnect_started = true;
#endif
@ -2523,7 +2523,7 @@ namespace libtorrent
m_torrent.reset();
}
#if !defined NDEBUG && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
#if defined TORRENT_DEBUG && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
// since this connection doesn't have a torrent reference
// no torrent should have a reference to this connection either
for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin()
@ -2748,7 +2748,7 @@ namespace libtorrent
m_recv_pos -= size;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::fill(m_recv_buffer.begin() + m_recv_pos, m_recv_buffer.end(), 0);
#endif
@ -3537,12 +3537,12 @@ namespace libtorrent
TORRENT_ASSERT(m_recv_pos <= int(m_recv_buffer.size()
+ m_disk_recv_buffer_size));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
size_type cur_payload_dl = m_statistics.last_payload_downloaded();
size_type cur_protocol_dl = m_statistics.last_protocol_downloaded();
#endif
on_receive(error, bytes_transferred);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
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 +
@ -3639,7 +3639,7 @@ namespace libtorrent
void peer_connection::connect(int ticket)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// in case we disconnect here, we need to
// keep the connection alive until the
// exit invariant check is run
@ -3822,12 +3822,12 @@ namespace libtorrent
m_last_sent = time_now();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
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);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
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
@ -3840,7 +3840,7 @@ namespace libtorrent
setup_send();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void peer_connection::check_invariant() const
{
TORRENT_ASSERT(bool(m_disk_recv_buffer) == (m_disk_recv_buffer_size > 0));

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/bitfield.hpp"
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
#include "libtorrent/peer_connection.hpp"
#include "libtorrent/torrent.hpp"
#endif
@ -70,7 +70,7 @@ namespace libtorrent
#ifdef TORRENT_PICKER_LOG
std::cerr << "new piece_picker" << std::endl;
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
check_invariant();
#endif
}
@ -195,7 +195,7 @@ namespace libtorrent
m_downloads.erase(i);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void piece_picker::verify_pick(std::vector<piece_block> const& picked
, bitfield const& bits) const
@ -226,7 +226,7 @@ namespace libtorrent
}
}
#if defined TORRENT_PICKER_LOG || !defined NDEBUG
#if defined TORRENT_PICKER_LOG || defined TORRENT_DEBUG
void piece_picker::print_pieces() const
{
for (std::vector<int>::const_iterator i = m_priority_boundries.begin()
@ -787,7 +787,7 @@ namespace libtorrent
, has_index(index));
TORRENT_ASSERT(i != m_downloads.end());
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int num_blocks = blocks_in_piece(i->index);
for (int k = 0; k < num_blocks; ++k)
{
@ -1501,7 +1501,7 @@ namespace libtorrent
if (num_blocks <= 0) return;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
verify_pick(interesting_blocks, pieces);
verify_pick(backup_blocks, pieces);
verify_pick(backup_blocks2, pieces);
@ -1538,7 +1538,7 @@ namespace libtorrent
}
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// make sure that we at this point have added requests to all unrequested blocks
// in all downloading pieces
@ -1726,7 +1726,7 @@ namespace libtorrent
}
}
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
verify_pick(interesting_blocks, pieces);
#endif
if (num_blocks <= 0) return 0;
@ -1825,7 +1825,7 @@ namespace libtorrent
if (int(backup_blocks.size()) >= num_blocks) return num_blocks;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
verify_pick(backup_blocks, pieces);
#endif
return num_blocks;
@ -1871,7 +1871,7 @@ namespace libtorrent
int max_blocks = blocks_in_piece(index);
if ((int)i->finished < max_blocks) return false;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (int k = 0; k < max_blocks; ++k)
{
TORRENT_ASSERT(i->info[k].state == block_info::state_finished);

View File

@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/piece_picker.hpp"
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
#include "libtorrent/bt_peer_connection.hpp"
#endif
@ -150,7 +150,7 @@ namespace
tcp::endpoint const& m_ep;
};
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
struct match_peer_connection
{
match_peer_connection(peer_connection const& c)
@ -212,7 +212,7 @@ namespace libtorrent
// the number of blocks we want, but it will try to make the picked
// blocks be from whole pieces, possibly by returning more blocks
// than we requested.
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
error_code ec;
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec);
#endif
@ -314,7 +314,7 @@ namespace libtorrent
busy_pieces.begin(), busy_pieces.end()
, bind(&piece_picker::num_peers, boost::cref(p), _1) <
bind(&piece_picker::num_peers, boost::cref(p), _2));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
piece_picker::downloading_piece st;
p.piece_info(i->piece_index, st);
TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index));
@ -653,7 +653,7 @@ namespace libtorrent
i = m_peers.insert(std::make_pair(c.remote().address(), p));
#ifndef TORRENT_DISABLE_GEO_IP
int as = ses.as_for_ip(c.remote().address());
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
i->second.inet_as_num = as;
#endif
i->second.inet_as = ses.lookup_as(as);
@ -786,7 +786,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_GEO_IP
int as = ses.as_for_ip(remote.address());
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
i->second.inet_as_num = as;
#endif
i->second.inet_as = ses.lookup_as(as);
@ -1053,7 +1053,7 @@ namespace libtorrent
c.send_block_requests();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool policy::has_connection(const peer_connection* c)
{
// too expensive

View File

@ -136,7 +136,7 @@ namespace libtorrent
// turn off the filename checking in boost.filesystem
TORRENT_ASSERT(listen_port_range.first > 0);
TORRENT_ASSERT(listen_port_range.first < listen_port_range.second);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// this test was added after it came to my attention
// that devstudios managed c++ failed to generate
// correct code for boost.function
@ -180,7 +180,7 @@ namespace libtorrent
#ifdef TORRENT_MEMDEBUG
start_malloc_debug();
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
boost::function0<void> test = boost::ref(*m_impl);
TORRENT_ASSERT(!test.empty());
#endif

View File

@ -510,7 +510,7 @@ namespace aux {
// abort all connections
while (!m_connections.empty())
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int conn = m_connections.size();
#endif
(*m_connections.begin())->disconnect("stopping torrent");
@ -911,7 +911,7 @@ namespace aux {
boost::intrusive_ptr<peer_connection> c(
new bt_peer_connection(*this, s, endp, 0));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
c->m_in_constructor = false;
#endif
@ -929,7 +929,7 @@ namespace aux {
// too expensive
// INVARIANT_CHECK;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// for (aux::session_impl::torrent_map::const_iterator i = m_torrents.begin()
// , end(m_torrents.end()); i != end; ++i)
// TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p));
@ -1689,7 +1689,7 @@ namespace aux {
TORRENT_ASSERT(m_abort == true);
if (ec)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::cerr << ec.message() << "\n";
std::string err = ec.message();
#endif
@ -1704,7 +1704,7 @@ namespace aux {
session_impl::mutex_t::scoped_lock l(m_mutex);
/*
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (torrent_map::iterator i = m_torrents.begin();
i != m_torrents.end(); ++i)
{
@ -1728,7 +1728,7 @@ namespace aux {
{
std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator i
= m_torrents.find(info_hash);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator j
= m_torrents.begin(); j != m_torrents.end(); ++j)
{
@ -1942,7 +1942,7 @@ namespace aux {
t.delete_files();
t.abort();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
sha1_hash i_hash = t.torrent_file().info_hash();
#endif
t.set_queue_position(-1);
@ -2632,7 +2632,7 @@ namespace aux {
#endif
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void session_impl::check_invariant() const
{
int num_checking = std::count_if(m_queued_for_checking.begin()

View File

@ -75,7 +75,7 @@ POSSIBILITY OF SUCH DAMAGE.
//#define TORRENT_PARTIAL_HASH_LOG
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
#include <ios>
#include <iostream>
#include <iomanip>
@ -243,7 +243,7 @@ using boost::bind;
using namespace ::boost::multi_index;
using boost::multi_index::multi_index_container;
#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG)
#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG
namespace
{
using namespace libtorrent;
@ -465,7 +465,7 @@ namespace libtorrent
sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size)
{
TORRENT_ASSERT(!error());
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
hasher partial;
hasher whole;
int slot_size1 = piece_size;
@ -486,7 +486,7 @@ namespace libtorrent
if (error()) return sha1_hash(0);
ph.h.update(&m_scratch_buffer[0], slot_size);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
sha1_hash ret = ph.h.final();
TORRENT_ASSERT(ret == whole.final());
return ret;
@ -915,7 +915,7 @@ namespace libtorrent
return false;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
/*
void storage::shuffle()
{
@ -1010,7 +1010,7 @@ namespace libtorrent
TORRENT_ASSERT(offset < m_files.piece_size(slot));
TORRENT_ASSERT(size > 0);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::vector<file_slice> slices
= files().map_block(slot, offset, size);
TORRENT_ASSERT(!slices.empty());
@ -1047,7 +1047,7 @@ namespace libtorrent
size_type result = left_to_read;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int counter = 0;
#endif
@ -1064,7 +1064,7 @@ namespace libtorrent
if (read_bytes == 0) continue;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(int(slices.size()) > counter);
size_type slice_size = slices[counter].size;
TORRENT_ASSERT(slice_size == read_bytes);
@ -1132,7 +1132,7 @@ namespace libtorrent
TORRENT_ASSERT(offset >= 0);
TORRENT_ASSERT(size > 0);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::vector<file_slice> slices
= files().map_block(slot, offset, size);
TORRENT_ASSERT(!slices.empty());
@ -1167,7 +1167,7 @@ namespace libtorrent
TORRENT_ASSERT(left_to_write >= 0);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int counter = 0;
#endif
@ -1184,7 +1184,7 @@ namespace libtorrent
if (write_bytes == 0) continue;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(int(slices.size()) > counter);
size_type slice_size = slices[counter].size;
TORRENT_ASSERT(slice_size == write_bytes);
@ -1361,7 +1361,7 @@ namespace libtorrent
// since that is the size of the pool allocator's buffers
TORRENT_ASSERT(r.length <= 16 * 1024);
m_io_thread.add_job(j, handler);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
boost::recursive_mutex::scoped_lock l(m_mutex);
// if this assert is hit, it suggests
// that check_files was not successful
@ -1532,7 +1532,7 @@ namespace libtorrent
std::map<int, partial_hash>::iterator i = m_piece_hasher.find(piece_index);
if (i != m_piece_hasher.end())
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(i->second.offset > 0);
int hash_offset = i->second.offset;
TORRENT_ASSERT(offset >= hash_offset);
@ -2537,7 +2537,7 @@ namespace libtorrent
&& m_slot_to_piece[piece_index] >= 0)
{
#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG)
#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG
std::stringstream s;
s << "there is another piece at our slot, swapping..";
@ -2572,7 +2572,7 @@ namespace libtorrent
slot_index = piece_index;
#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG)
#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG
debug_log();
#endif
}
@ -2640,7 +2640,7 @@ namespace libtorrent
return m_slot_to_piece[slot];
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void piece_manager::check_invariant() const
{
boost::recursive_mutex::scoped_lock lock(m_mutex);

View File

@ -271,7 +271,7 @@ namespace libtorrent
m_obfuscated_hash = h.final();
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_files_checked = false;
#endif
INVARIANT_CHECK;
@ -1235,7 +1235,7 @@ namespace libtorrent
if (m_picker->have_piece(index)) continue;
TORRENT_ASSERT(i->finished <= m_picker->blocks_in_piece(index));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (std::vector<piece_picker::downloading_piece>::const_iterator j = boost::next(i);
j != dl_queue.end(); ++j)
{
@ -1295,7 +1295,7 @@ namespace libtorrent
{
downloading_piece[block] = p->bytes_downloaded;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(p->bytes_downloaded <= p->full_block_bytes);
int last_piece = m_torrent_file->num_pieces() - 1;
if (p->piece_index == last_piece
@ -1317,7 +1317,7 @@ namespace libtorrent
TORRENT_ASSERT(total_done <= m_torrent_file->total_size());
TORRENT_ASSERT(wanted_done <= m_torrent_file->total_size());
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
if (total_done >= m_torrent_file->total_size())
{
@ -1512,7 +1512,7 @@ namespace libtorrent
std::set<void*> peers;
std::copy(downloaders.begin(), downloaders.end(), std::inserter(peers, peers.begin()));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (std::vector<void*>::iterator i = downloaders.begin()
, end(downloaders.end()); i != end; ++i)
{
@ -1594,7 +1594,7 @@ namespace libtorrent
TORRENT_ASSERT(m_picker->have_piece(index) == false);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (std::vector<void*>::iterator i = downloaders.begin()
, end(downloaders.end()); i != end; ++i)
{
@ -2407,7 +2407,7 @@ namespace libtorrent
m_ses, shared_from_this(), s, a, url, 0));
if (!c) return;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
c->m_in_constructor = false;
#endif
@ -2980,7 +2980,7 @@ namespace libtorrent
TORRENT_ASSERT(peerinfo->connection == 0);
peerinfo->connected = time_now();
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// this asserts that we don't have duplicates in the policy's peer list
peer_iterator i_ = std::find_if(m_connections.begin(), m_connections.end()
, bind(&peer_connection::remote, _1) == peerinfo->ip());
@ -3003,7 +3003,7 @@ namespace libtorrent
boost::intrusive_ptr<peer_connection> c(new bt_peer_connection(
m_ses, shared_from_this(), s, a, peerinfo));
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
c->m_in_constructor = false;
#endif
@ -3169,12 +3169,12 @@ namespace libtorrent
#endif
TORRENT_ASSERT(m_connections.find(p) == m_connections.end());
peer_iterator ci = m_connections.insert(p).first;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
error_code ec;
TORRENT_ASSERT(p->remote() == p->get_socket()->remote_endpoint(ec) || ec);
#endif
#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
m_policy.check_invariant();
#endif
return true;
@ -3210,7 +3210,7 @@ namespace libtorrent
else
(*p->m_logger) << "*** CLOSING CONNECTION 'pausing'\n";
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::size_t size = m_connections.size();
#endif
if (p->is_disconnecting())
@ -3632,7 +3632,7 @@ namespace libtorrent
return m_ses.settings();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void torrent::check_invariant() const
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
@ -4387,7 +4387,7 @@ namespace libtorrent
TORRENT_ASSERT(piece_index >= 0);
TORRENT_ASSERT(piece_index < m_torrent_file->num_pieces());
TORRENT_ASSERT(piece_index < (int)m_picker->num_pieces());
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
if (m_picker)
{
int blocks_in_piece = m_picker->blocks_in_piece(piece_index);
@ -4400,7 +4400,7 @@ namespace libtorrent
m_storage->async_hash(piece_index, bind(&torrent::on_piece_verified
, shared_from_this(), _1, _2, f));
#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
check_invariant();
#endif
}
@ -4590,7 +4590,7 @@ namespace libtorrent
void torrent::set_state(torrent_status::state_t s)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
if (s == torrent_status::seeding)
TORRENT_ASSERT(is_seed());
if (s == torrent_status::finished)

View File

@ -134,7 +134,7 @@ namespace libtorrent
#endif
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void torrent_handle::check_invariant() const
{}

View File

@ -25,12 +25,12 @@ udp_socket::udp_socket(asio::io_service& ios, udp_socket::callback_t const& c
, m_resolver(ios)
, m_tunnel_packets(false)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_magic = 0x1337;
#endif
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
#define CHECK_MAGIC check_magic_ cm_(m_magic)
struct check_magic_
{

View File

@ -695,7 +695,7 @@ namespace libtorrent
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void web_peer_connection::check_invariant() const
{
/*