lt sync 2994

This commit is contained in:
Andrew Resch 2008-11-29 21:53:57 +00:00
commit cfec86be75
47 changed files with 210 additions and 206 deletions

View file

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

View file

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

View file

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

View file

@ -233,7 +233,7 @@ namespace libtorrent
void on_connected(); void on_connected();
void on_metadata(); void on_metadata();
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void check_invariant() const; void check_invariant() const;
ptime m_last_choke; ptime m_last_choke;
#endif #endif
@ -407,7 +407,7 @@ private:
boost::scoped_ptr<sha1_hash> m_sync_hash; boost::scoped_ptr<sha1_hash> m_sync_hash;
#endif // #ifndef TORRENT_DISABLE_ENCRYPTION #endif // #ifndef TORRENT_DISABLE_ENCRYPTION
#ifndef NDEBUG #ifdef TORRENT_DEBUG
// 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; bool m_sent_bitfield;

View file

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

View file

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

View file

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

View file

@ -124,7 +124,7 @@ namespace libtorrent
#else #else
int m_fd; int m_fd;
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
open_mode m_open_mode; open_mode m_open_mode;
#endif #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 \ #define INVARIANT_CHECK \
invariant_checker const& _invariant_check = make_invariant_checker(*this); \ invariant_checker const& _invariant_check = make_invariant_checker(*this); \
(void)_invariant_check; \ (void)_invariant_check; \

View file

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

View file

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

View file

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

View file

@ -396,7 +396,7 @@ namespace libtorrent
void assign_bandwidth(int channel, int amount); void assign_bandwidth(int channel, int amount);
void expire_bandwidth(int channel, int amount); void expire_bandwidth(int channel, int amount);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void check_invariant() const; void check_invariant() const;
ptime m_last_choke; ptime m_last_choke;
#endif #endif
@ -458,7 +458,7 @@ namespace libtorrent
bool packet_finished() const bool packet_finished() const
{ return m_packet_size <= m_recv_pos; } { return m_packet_size <= m_recv_pos; }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
bool piece_failed; bool piece_failed;
#endif #endif
@ -566,7 +566,7 @@ namespace libtorrent
char m_country[2]; char m_country[2];
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
boost::intrusive_ptr<peer_connection> self() boost::intrusive_ptr<peer_connection> self()
{ {
TORRENT_ASSERT(!m_in_constructor); TORRENT_ASSERT(!m_in_constructor);
@ -870,7 +870,7 @@ namespace libtorrent
// this is set to true once the bitfield is received // this is set to true once the bitfield is received
bool m_bitfield_received:1; bool m_bitfield_received:1;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
public: public:
bool m_in_constructor:1; bool m_in_constructor:1;
bool m_disconnect_started:1; bool m_disconnect_started:1;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -147,7 +147,7 @@ namespace libtorrent
, void* userdata); , void* userdata);
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
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
@ -431,7 +431,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed()); TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount(index); m_picker->inc_refcount(index);
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
else else
{ {
TORRENT_ASSERT(is_seed()); TORRENT_ASSERT(is_seed());
@ -447,7 +447,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed()); TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount(bits); m_picker->inc_refcount(bits);
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
else else
{ {
TORRENT_ASSERT(is_seed()); TORRENT_ASSERT(is_seed());
@ -462,7 +462,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed()); TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount_all(); m_picker->inc_refcount_all();
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
else else
{ {
TORRENT_ASSERT(is_seed()); TORRENT_ASSERT(is_seed());
@ -477,7 +477,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed()); TORRENT_ASSERT(!is_seed());
m_picker->dec_refcount(index); m_picker->dec_refcount(index);
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
else else
{ {
TORRENT_ASSERT(is_seed()); TORRENT_ASSERT(is_seed());
@ -596,7 +596,7 @@ namespace libtorrent
#endif #endif
// DEBUG // DEBUG
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void check_invariant() const; void check_invariant() const;
#endif #endif
@ -718,11 +718,11 @@ namespace libtorrent
// the time of next tracker announce // the time of next tracker announce
ptime m_next_tracker_announce; ptime m_next_tracker_announce;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
public: public:
#endif #endif
std::set<peer_connection*> m_connections; std::set<peer_connection*> m_connections;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
private: private:
#endif #endif
@ -872,7 +872,7 @@ namespace libtorrent
int m_complete; int m_complete;
int m_incomplete; int m_incomplete;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
// this is the amount downloaded when this torrent // this is the amount downloaded when this torrent
// is started. i.e. // is started. i.e.
// total_done - m_initial_done <= total_payload_download // total_done - m_initial_done <= total_payload_download

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -107,7 +107,7 @@ namespace libtorrent
, m_sync_bytes_read(0) , m_sync_bytes_read(0)
, m_enc_send_buffer(0, 0) , m_enc_send_buffer(0, 0)
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
, m_sent_bitfield(false) , m_sent_bitfield(false)
, m_in_constructor(true) , m_in_constructor(true)
, m_sent_handshake(false) , m_sent_handshake(false)
@ -117,7 +117,7 @@ namespace libtorrent
(*m_logger) << "*** bt_peer_connection\n"; (*m_logger) << "*** bt_peer_connection\n";
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_in_constructor = false; m_in_constructor = false;
#endif #endif
} }
@ -140,7 +140,7 @@ namespace libtorrent
, m_sync_bytes_read(0) , m_sync_bytes_read(0)
, m_enc_send_buffer(0, 0) , m_enc_send_buffer(0, 0)
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
, m_sent_bitfield(false) , m_sent_bitfield(false)
, m_in_constructor(true) , m_in_constructor(true)
, m_sent_handshake(false) , m_sent_handshake(false)
@ -164,7 +164,7 @@ namespace libtorrent
m_bandwidth_limit[upload_channel].assign(80); m_bandwidth_limit[upload_channel].assign(80);
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_in_constructor = false; m_in_constructor = false;
#endif #endif
} }
@ -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);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
@ -293,7 +293,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
@ -695,7 +695,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(!m_sent_handshake); TORRENT_ASSERT(!m_sent_handshake);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_sent_handshake = true; m_sent_handshake = true;
#endif #endif
@ -1452,7 +1452,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " *** NOT SENDING BITFIELD\n"; (*m_logger) << time_now_string() << " *** NOT SENDING BITFIELD\n";
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
return; return;
@ -1521,7 +1521,7 @@ namespace libtorrent
bitfield_string << "\n"; bitfield_string << "\n";
(*m_logger) << bitfield_string.str(); (*m_logger) << bitfield_string.str();
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_sent_bitfield = true; m_sent_bitfield = true;
#endif #endif
@ -2632,7 +2632,7 @@ namespace libtorrent
m_statistics.sent_bytes(amount_payload, bytes_transferred - amount_payload); m_statistics.sent_bytes(amount_payload, bytes_transferred - amount_payload);
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void bt_peer_connection::check_invariant() const void bt_peer_connection::check_invariant() const
{ {
#ifndef TORRENT_DISABLE_ENCRYPTION #ifndef TORRENT_DISABLE_ENCRYPTION

View file

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

View file

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

View file

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

View file

@ -142,7 +142,7 @@ namespace libtorrent
#else #else
: m_fd(-1) : m_fd(-1)
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
, m_open_mode(0) , m_open_mode(0)
#endif #endif
{} {}
@ -153,7 +153,7 @@ namespace libtorrent
#else #else
: m_fd(-1) : m_fd(-1)
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
, m_open_mode(0) , m_open_mode(0)
#endif #endif
{ {
@ -214,7 +214,7 @@ namespace libtorrent
return false; return false;
} }
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_open_mode = mode; m_open_mode = mode;
#endif #endif
TORRENT_ASSERT(is_open()); TORRENT_ASSERT(is_open());
@ -241,7 +241,7 @@ namespace libtorrent
::close(m_fd); ::close(m_fd);
m_fd = -1; m_fd = -1;
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_open_mode = 0; m_open_mode = 0;
#endif #endif
} }

View file

@ -271,7 +271,7 @@ namespace
std::lower_bound(name_map, name_map + size std::lower_bound(name_map, name_map + size
, tmp, &compare_id); , tmp, &compare_id);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
for (int i = 1; i < size; ++i) for (int i = 1; i < size; ++i)
{ {
TORRENT_ASSERT(compare_id(name_map[i-1] TORRENT_ASSERT(compare_id(name_map[i-1]

View file

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

View file

@ -239,7 +239,7 @@ namespace libtorrent { namespace dht
} }
catch (std::exception& exc) catch (std::exception& exc)
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
std::cerr << "exception-type: " << typeid(exc).name() << std::endl; std::cerr << "exception-type: " << typeid(exc).name() << std::endl;
std::cerr << "what: " << exc.what() << std::endl; std::cerr << "what: " << exc.what() << std::endl;
TORRENT_ASSERT(false); TORRENT_ASSERT(false);

View file

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

View file

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

View file

@ -104,7 +104,7 @@ void refresh::invoke(node_id const& nid, udp::endpoint addr)
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(refresh_observer)); TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(refresh_observer));
observer_ptr o(new (m_rpc.allocator().malloc()) refresh_observer( observer_ptr o(new (m_rpc.allocator().malloc()) refresh_observer(
this, nid, m_target)); this, nid, m_target));
#ifndef NDEBUG #ifdef TORRENT_DEBUG
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
@ -159,7 +159,7 @@ void refresh::invoke_pings_or_finish(bool prevent_request)
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(ping_observer)); TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(ping_observer));
observer_ptr o(new (m_rpc.allocator().malloc()) ping_observer( observer_ptr o(new (m_rpc.allocator().malloc()) ping_observer(
this, node.id)); this, node.id));
#ifndef NDEBUG #ifdef TORRENT_DEBUG
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
m_rpc.invoke(messages::ping, node.addr, o); 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 rpc_manager::allocation_size() const
{ {
size_t s = sizeof(mpl::deref<max_observer_type_iter::base>::type); size_t s = sizeof(mpl::deref<max_observer_type_iter::base>::type);
@ -423,7 +423,7 @@ void rpc_manager::invoke(int message_id, udp::endpoint target_addr
m.id = m_our_id; m.id = m_our_id;
m.addr = target_addr; m.addr = target_addr;
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]); TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
int potential_new_id = m_next_transaction_id; int potential_new_id = m_next_transaction_id;
#endif #endif
try try
@ -481,7 +481,7 @@ void rpc_manager::reply_with_ping(msg& m)
TORRENT_ASSERT(allocation_size() >= sizeof(null_observer)); TORRENT_ASSERT(allocation_size() >= sizeof(null_observer));
observer_ptr o(new (allocator().malloc()) null_observer(allocator())); observer_ptr o(new (allocator().malloc()) null_observer(allocator()));
#ifndef NDEBUG #ifdef TORRENT_DEBUG
o->m_in_constructor = false; o->m_in_constructor = false;
#endif #endif
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]); TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);

View file

@ -69,7 +69,7 @@ namespace libtorrent
, tcp::endpoint const& endp , tcp::endpoint const& endp
, policy::peer* peerinfo) , policy::peer* peerinfo)
: :
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_last_choke(time_now() - hours(1)) m_last_choke(time_now() - hours(1))
, ,
#endif #endif
@ -130,7 +130,7 @@ namespace libtorrent
, m_upload_only(false) , m_upload_only(false)
, m_snubbed(false) , m_snubbed(false)
, m_bitfield_received(false) , m_bitfield_received(false)
#ifndef NDEBUG #ifdef TORRENT_DEBUG
, m_in_constructor(true) , m_in_constructor(true)
, m_disconnect_started(false) , m_disconnect_started(false)
, m_initialized(false) , m_initialized(false)
@ -160,7 +160,7 @@ namespace libtorrent
+ boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port()); + boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port());
(*m_logger) << "*** OUTGOING CONNECTION\n"; (*m_logger) << "*** OUTGOING CONNECTION\n";
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
piece_failed = false; piece_failed = false;
#endif #endif
#ifndef TORRENT_DISABLE_GEO_IP #ifndef TORRENT_DISABLE_GEO_IP
@ -177,7 +177,7 @@ namespace libtorrent
, tcp::endpoint const& endp , tcp::endpoint const& endp
, policy::peer* peerinfo) , policy::peer* peerinfo)
: :
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_last_choke(time_now() - hours(1)) m_last_choke(time_now() - hours(1))
, ,
#endif #endif
@ -237,7 +237,7 @@ namespace libtorrent
, m_upload_only(false) , m_upload_only(false)
, m_snubbed(false) , m_snubbed(false)
, m_bitfield_received(false) , m_bitfield_received(false)
#ifndef NDEBUG #ifdef TORRENT_DEBUG
, m_in_constructor(true) , m_in_constructor(true)
, m_disconnect_started(false) , m_disconnect_started(false)
, m_initialized(false) , m_initialized(false)
@ -272,7 +272,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_GEO_IP #ifndef TORRENT_DISABLE_GEO_IP
m_inet_as_name = m_ses.as_name_for_ip(m_remote.address()); m_inet_as_name = m_ses.as_name_for_ip(m_remote.address());
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
piece_failed = false; piece_failed = false;
#endif #endif
std::fill(m_peer_id.begin(), m_peer_id.end(), 0); std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
@ -518,7 +518,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();
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_initialized = true; m_initialized = true;
#endif #endif
// now that we have a piece_picker, // now that we have a piece_picker,
@ -582,7 +582,7 @@ namespace libtorrent
} }
#endif #endif
TORRENT_ASSERT(!m_ses.has_peer(this)); 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() 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));
@ -684,7 +684,7 @@ namespace libtorrent
<< " ==> HAVE [ piece: " << index << "]\n"; << " ==> HAVE [ piece: " << index << "]\n";
#endif #endif
write_have(index); write_have(index);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
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->have_piece(index)); TORRENT_ASSERT(t->have_piece(index));
@ -862,12 +862,12 @@ namespace libtorrent
TORRENT_ASSERT(m_torrent.expired()); TORRENT_ASSERT(m_torrent.expired());
// check to make sure we don't have another connection with the same // check to make sure we don't have another connection with the same
// info_hash and peer_id. If we do. close this connection. // info_hash and peer_id. If we do. close this connection.
#ifndef NDEBUG #ifdef TORRENT_DEBUG
try try
{ {
#endif #endif
t->attach_peer(this); t->attach_peer(this);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
} }
catch (std::exception& e) catch (std::exception& e)
{ {
@ -1563,7 +1563,7 @@ namespace libtorrent
m_last_piece = time_now(); m_last_piece = time_now();
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
struct check_postcondition struct check_postcondition
{ {
check_postcondition(boost::shared_ptr<torrent> const& t_ check_postcondition(boost::shared_ptr<torrent> const& t_
@ -1644,7 +1644,7 @@ namespace libtorrent
#endif #endif
if (is_disconnecting()) return; if (is_disconnecting()) return;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
check_postcondition post_checker_(t); check_postcondition post_checker_(t);
#if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS #if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
t->check_invariant(); t->check_invariant();
@ -1723,7 +1723,7 @@ namespace libtorrent
send_block_requests(); send_block_requests();
return; return;
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
pending_block pending_b = *b; pending_block pending_b = *b;
#endif #endif
@ -1821,7 +1821,7 @@ namespace libtorrent
TORRENT_ASSERT(picker.num_peers(block_finished) == 0); 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 && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
t->check_invariant(); t->check_invariant();
#endif #endif
@ -1883,7 +1883,7 @@ namespace libtorrent
// did we just finish the piece? // did we just finish the piece?
if (picker.is_piece_finished(p.piece)) if (picker.is_piece_finished(p.piece))
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
check_postcondition post_checker2_(t, false); check_postcondition post_checker2_(t, false);
#endif #endif
t->async_verify_piece(p.piece, bind(&torrent::piece_finished, t t->async_verify_piece(p.piece, bind(&torrent::piece_finished, t
@ -2248,7 +2248,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " ==> CHOKE\n"; (*m_logger) << time_now_string() << " ==> CHOKE\n";
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_last_choke = time_now(); m_last_choke = time_now();
#endif #endif
m_num_invalid_requests = 0; m_num_invalid_requests = 0;
@ -2461,7 +2461,7 @@ namespace libtorrent
{ {
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_disconnect_started = true; m_disconnect_started = true;
#endif #endif
@ -2537,7 +2537,7 @@ namespace libtorrent
m_torrent.reset(); 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 // since this connection doesn't have a torrent reference
// no torrent should have a reference to this connection either // no torrent should have a reference to this connection either
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()
@ -2761,7 +2761,7 @@ namespace libtorrent
m_recv_pos -= size; m_recv_pos -= size;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
std::fill(m_recv_buffer.begin() + m_recv_pos, m_recv_buffer.end(), 0); std::fill(m_recv_buffer.begin() + m_recv_pos, m_recv_buffer.end(), 0);
#endif #endif
@ -3632,7 +3632,7 @@ namespace libtorrent
void peer_connection::connect(int ticket) void peer_connection::connect(int ticket)
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
// 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
@ -3816,7 +3816,7 @@ namespace libtorrent
setup_send(); setup_send();
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void peer_connection::check_invariant() const void peer_connection::check_invariant() const
{ {
TORRENT_ASSERT(bool(m_disk_recv_buffer) == (m_disk_recv_buffer_size > 0)); 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/aux_/session_impl.hpp"
#include "libtorrent/bitfield.hpp" #include "libtorrent/bitfield.hpp"
#ifndef NDEBUG #ifdef TORRENT_DEBUG
#include "libtorrent/peer_connection.hpp" #include "libtorrent/peer_connection.hpp"
#include "libtorrent/torrent.hpp" #include "libtorrent/torrent.hpp"
#endif #endif
@ -70,7 +70,7 @@ namespace libtorrent
#ifdef TORRENT_PICKER_LOG #ifdef TORRENT_PICKER_LOG
std::cerr << "new piece_picker" << std::endl; std::cerr << "new piece_picker" << std::endl;
#endif #endif
#ifndef NDEBUG #ifdef TORRENT_DEBUG
check_invariant(); check_invariant();
#endif #endif
} }
@ -195,7 +195,7 @@ namespace libtorrent
m_downloads.erase(i); m_downloads.erase(i);
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void piece_picker::verify_pick(std::vector<piece_block> const& picked void piece_picker::verify_pick(std::vector<piece_block> const& picked
, bitfield const& bits) const , 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 void piece_picker::print_pieces() const
{ {
for (std::vector<int>::const_iterator i = m_priority_boundries.begin() for (std::vector<int>::const_iterator i = m_priority_boundries.begin()
@ -787,7 +787,7 @@ namespace libtorrent
, has_index(index)); , has_index(index));
TORRENT_ASSERT(i != m_downloads.end()); TORRENT_ASSERT(i != m_downloads.end());
#ifndef NDEBUG #ifdef TORRENT_DEBUG
int num_blocks = blocks_in_piece(i->index); int num_blocks = blocks_in_piece(i->index);
for (int k = 0; k < num_blocks; ++k) for (int k = 0; k < num_blocks; ++k)
{ {
@ -1501,7 +1501,7 @@ namespace libtorrent
if (num_blocks <= 0) return; if (num_blocks <= 0) return;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
verify_pick(interesting_blocks, pieces); verify_pick(interesting_blocks, pieces);
verify_pick(backup_blocks, pieces); verify_pick(backup_blocks, pieces);
verify_pick(backup_blocks2, 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 // make sure that we at this point have added requests to all unrequested blocks
// in all downloading pieces // in all downloading pieces
@ -1726,7 +1726,7 @@ namespace libtorrent
} }
} }
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
verify_pick(interesting_blocks, pieces); verify_pick(interesting_blocks, pieces);
#endif #endif
if (num_blocks <= 0) return 0; if (num_blocks <= 0) return 0;
@ -1825,7 +1825,7 @@ namespace libtorrent
if (int(backup_blocks.size()) >= num_blocks) return num_blocks; if (int(backup_blocks.size()) >= num_blocks) return num_blocks;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
verify_pick(backup_blocks, pieces); verify_pick(backup_blocks, pieces);
#endif #endif
return num_blocks; return num_blocks;
@ -1871,7 +1871,7 @@ namespace libtorrent
int max_blocks = blocks_in_piece(index); int max_blocks = blocks_in_piece(index);
if ((int)i->finished < max_blocks) return false; if ((int)i->finished < max_blocks) return false;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
for (int k = 0; k < max_blocks; ++k) for (int k = 0; k < max_blocks; ++k)
{ {
TORRENT_ASSERT(i->info[k].state == block_info::state_finished); 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/aux_/session_impl.hpp"
#include "libtorrent/piece_picker.hpp" #include "libtorrent/piece_picker.hpp"
#ifndef NDEBUG #ifdef TORRENT_DEBUG
#include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp"
#endif #endif
@ -150,7 +150,7 @@ namespace
tcp::endpoint const& m_ep; tcp::endpoint const& m_ep;
}; };
#ifndef NDEBUG #ifdef TORRENT_DEBUG
struct match_peer_connection struct match_peer_connection
{ {
match_peer_connection(peer_connection const& c) match_peer_connection(peer_connection const& c)
@ -211,7 +211,7 @@ namespace libtorrent
// the number of blocks we want, but it will try to make the picked // the number of blocks we want, but it will try to make the picked
// blocks be from whole pieces, possibly by returning more blocks // blocks be from whole pieces, possibly by returning more blocks
// than we requested. // than we requested.
#ifndef NDEBUG #ifdef TORRENT_DEBUG
error_code ec; error_code ec;
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec); TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec);
#endif #endif
@ -313,7 +313,7 @@ namespace libtorrent
busy_pieces.begin(), busy_pieces.end() busy_pieces.begin(), busy_pieces.end()
, bind(&piece_picker::num_peers, boost::cref(p), _1) < , bind(&piece_picker::num_peers, boost::cref(p), _1) <
bind(&piece_picker::num_peers, boost::cref(p), _2)); bind(&piece_picker::num_peers, boost::cref(p), _2));
#ifndef NDEBUG #ifdef TORRENT_DEBUG
piece_picker::downloading_piece st; piece_picker::downloading_piece st;
p.piece_info(i->piece_index, st); p.piece_info(i->piece_index, st);
TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index)); TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index));
@ -652,7 +652,7 @@ namespace libtorrent
i = m_peers.insert(std::make_pair(c.remote().address(), p)); i = m_peers.insert(std::make_pair(c.remote().address(), p));
#ifndef TORRENT_DISABLE_GEO_IP #ifndef TORRENT_DISABLE_GEO_IP
int as = ses.as_for_ip(c.remote().address()); int as = ses.as_for_ip(c.remote().address());
#ifndef NDEBUG #ifdef TORRENT_DEBUG
i->second.inet_as_num = as; i->second.inet_as_num = as;
#endif #endif
i->second.inet_as = ses.lookup_as(as); i->second.inet_as = ses.lookup_as(as);
@ -785,7 +785,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_GEO_IP #ifndef TORRENT_DISABLE_GEO_IP
int as = ses.as_for_ip(remote.address()); int as = ses.as_for_ip(remote.address());
#ifndef NDEBUG #ifdef TORRENT_DEBUG
i->second.inet_as_num = as; i->second.inet_as_num = as;
#endif #endif
i->second.inet_as = ses.lookup_as(as); i->second.inet_as = ses.lookup_as(as);
@ -1052,7 +1052,7 @@ namespace libtorrent
c.send_block_requests(); c.send_block_requests();
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
bool policy::has_connection(const peer_connection* c) bool policy::has_connection(const peer_connection* c)
{ {
// too expensive // too expensive

View file

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

View file

@ -506,7 +506,7 @@ namespace aux {
// abort all connections // abort all connections
while (!m_connections.empty()) while (!m_connections.empty())
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
int conn = m_connections.size(); int conn = m_connections.size();
#endif #endif
(*m_connections.begin())->disconnect("stopping torrent"); (*m_connections.begin())->disconnect("stopping torrent");
@ -907,7 +907,7 @@ namespace aux {
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));
#ifndef NDEBUG #ifdef TORRENT_DEBUG
c->m_in_constructor = false; c->m_in_constructor = false;
#endif #endif
@ -925,7 +925,7 @@ namespace aux {
// too expensive // too expensive
// INVARIANT_CHECK; // INVARIANT_CHECK;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
// for (aux::session_impl::torrent_map::const_iterator i = m_torrents.begin() // for (aux::session_impl::torrent_map::const_iterator i = m_torrents.begin()
// , end(m_torrents.end()); i != end; ++i) // , end(m_torrents.end()); i != end; ++i)
// TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p)); // TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p));
@ -1621,7 +1621,7 @@ namespace aux {
TORRENT_ASSERT(m_abort == true); TORRENT_ASSERT(m_abort == true);
if (ec) if (ec)
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
std::cerr << ec.message() << "\n"; std::cerr << ec.message() << "\n";
std::string err = ec.message(); std::string err = ec.message();
#endif #endif
@ -1636,7 +1636,7 @@ namespace aux {
session_impl::mutex_t::scoped_lock l(m_mutex); session_impl::mutex_t::scoped_lock l(m_mutex);
/* /*
#ifndef NDEBUG #ifdef TORRENT_DEBUG
for (torrent_map::iterator i = m_torrents.begin(); for (torrent_map::iterator i = m_torrents.begin();
i != m_torrents.end(); ++i) i != m_torrents.end(); ++i)
{ {
@ -1660,7 +1660,7 @@ namespace aux {
{ {
std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator i std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator i
= m_torrents.find(info_hash); = m_torrents.find(info_hash);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
for (std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator j for (std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator j
= m_torrents.begin(); j != m_torrents.end(); ++j) = m_torrents.begin(); j != m_torrents.end(); ++j)
{ {
@ -1851,7 +1851,7 @@ namespace aux {
t.delete_files(); t.delete_files();
t.abort(); t.abort();
#ifndef NDEBUG #ifdef TORRENT_DEBUG
sha1_hash i_hash = t.torrent_file().info_hash(); sha1_hash i_hash = t.torrent_file().info_hash();
#endif #endif
t.set_queue_position(-1); t.set_queue_position(-1);
@ -2503,7 +2503,7 @@ namespace aux {
#endif #endif
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void session_impl::check_invariant() const void session_impl::check_invariant() const
{ {
std::set<int> unique; std::set<int> unique;

View file

@ -75,7 +75,7 @@ POSSIBILITY OF SUCH DAMAGE.
//#define TORRENT_PARTIAL_HASH_LOG //#define TORRENT_PARTIAL_HASH_LOG
#ifndef NDEBUG #ifdef TORRENT_DEBUG
#include <ios> #include <ios>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
@ -242,7 +242,7 @@ using boost::bind;
using namespace ::boost::multi_index; using namespace ::boost::multi_index;
using boost::multi_index::multi_index_container; using boost::multi_index::multi_index_container;
#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG) #if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG
namespace namespace
{ {
using namespace libtorrent; using namespace libtorrent;
@ -463,7 +463,7 @@ namespace libtorrent
sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size) sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size)
{ {
TORRENT_ASSERT(!error()); TORRENT_ASSERT(!error());
#ifndef NDEBUG #ifdef TORRENT_DEBUG
hasher partial; hasher partial;
hasher whole; hasher whole;
int slot_size1 = piece_size; int slot_size1 = piece_size;
@ -484,7 +484,7 @@ namespace libtorrent
if (error()) return sha1_hash(0); if (error()) return sha1_hash(0);
ph.h.update(&m_scratch_buffer[0], slot_size); ph.h.update(&m_scratch_buffer[0], slot_size);
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
sha1_hash ret = ph.h.final(); sha1_hash ret = ph.h.final();
TORRENT_ASSERT(ret == whole.final()); TORRENT_ASSERT(ret == whole.final());
return ret; return ret;
@ -904,7 +904,7 @@ namespace libtorrent
return false; return false;
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
/* /*
void storage::shuffle() void storage::shuffle()
{ {
@ -999,7 +999,7 @@ namespace libtorrent
TORRENT_ASSERT(offset < m_files.piece_size(slot)); TORRENT_ASSERT(offset < m_files.piece_size(slot));
TORRENT_ASSERT(size > 0); TORRENT_ASSERT(size > 0);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
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());
@ -1046,7 +1046,7 @@ namespace libtorrent
return size; return size;
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
size_type in_tell = in->tell(ec); size_type in_tell = in->tell(ec);
TORRENT_ASSERT(in_tell == file_offset + file_iter->file_base && !ec); TORRENT_ASSERT(in_tell == file_offset + file_iter->file_base && !ec);
#endif #endif
@ -1061,7 +1061,7 @@ namespace libtorrent
size_type result = left_to_read; size_type result = left_to_read;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
int counter = 0; int counter = 0;
#endif #endif
@ -1073,7 +1073,7 @@ namespace libtorrent
if (read_bytes > 0) if (read_bytes > 0)
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
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 == read_bytes); TORRENT_ASSERT(slice_size == read_bytes);
@ -1105,7 +1105,7 @@ namespace libtorrent
if (left_to_read > 0) if (left_to_read > 0)
{ {
++file_iter; ++file_iter;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
// empty files are not returned by map_block, so if // empty files are not returned by map_block, so if
// this file was empty, don't increment the slice counter // this file was empty, don't increment the slice counter
if (read_bytes > 0) ++counter; if (read_bytes > 0) ++counter;
@ -1148,7 +1148,7 @@ namespace libtorrent
TORRENT_ASSERT(offset >= 0); TORRENT_ASSERT(offset >= 0);
TORRENT_ASSERT(size > 0); TORRENT_ASSERT(size > 0);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
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());
@ -1200,7 +1200,7 @@ namespace libtorrent
TORRENT_ASSERT(left_to_write >= 0); TORRENT_ASSERT(left_to_write >= 0);
int buf_pos = 0; int buf_pos = 0;
#ifndef NDEBUG #ifdef TORRENT_DEBUG
int counter = 0; int counter = 0;
#endif #endif
while (left_to_write > 0) while (left_to_write > 0)
@ -1239,7 +1239,7 @@ namespace libtorrent
if (left_to_write > 0) if (left_to_write > 0)
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
if (write_bytes > 0) ++counter; if (write_bytes > 0) ++counter;
#endif #endif
++file_iter; ++file_iter;
@ -1403,7 +1403,7 @@ namespace libtorrent
// since that is the size of the pool allocator's buffers // since that is the size of the pool allocator's buffers
TORRENT_ASSERT(r.length <= 16 * 1024); TORRENT_ASSERT(r.length <= 16 * 1024);
m_io_thread.add_job(j, handler); m_io_thread.add_job(j, handler);
#ifndef NDEBUG #ifdef TORRENT_DEBUG
boost::recursive_mutex::scoped_lock l(m_mutex); boost::recursive_mutex::scoped_lock l(m_mutex);
// if this assert is hit, it suggests // if this assert is hit, it suggests
// that check_files was not successful // that check_files was not successful
@ -1574,7 +1574,7 @@ namespace libtorrent
std::map<int, partial_hash>::iterator i = m_piece_hasher.find(piece_index); std::map<int, partial_hash>::iterator i = m_piece_hasher.find(piece_index);
if (i != m_piece_hasher.end()) if (i != m_piece_hasher.end())
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
TORRENT_ASSERT(i->second.offset > 0); TORRENT_ASSERT(i->second.offset > 0);
int hash_offset = i->second.offset; int hash_offset = i->second.offset;
TORRENT_ASSERT(offset >= hash_offset); TORRENT_ASSERT(offset >= hash_offset);
@ -2579,7 +2579,7 @@ namespace libtorrent
&& m_slot_to_piece[piece_index] >= 0) && 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; std::stringstream s;
s << "there is another piece at our slot, swapping.."; s << "there is another piece at our slot, swapping..";
@ -2614,7 +2614,7 @@ namespace libtorrent
slot_index = piece_index; slot_index = piece_index;
#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG) #if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG
debug_log(); debug_log();
#endif #endif
} }
@ -2682,7 +2682,7 @@ namespace libtorrent
return m_slot_to_piece[slot]; return m_slot_to_piece[slot];
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void piece_manager::check_invariant() const void piece_manager::check_invariant() const
{ {
boost::recursive_mutex::scoped_lock lock(m_mutex); boost::recursive_mutex::scoped_lock lock(m_mutex);

View file

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

View file

@ -134,7 +134,7 @@ namespace libtorrent
#endif #endif
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
void torrent_handle::check_invariant() const 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_resolver(ios)
, m_tunnel_packets(false) , m_tunnel_packets(false)
{ {
#ifndef NDEBUG #ifdef TORRENT_DEBUG
m_magic = 0x1337; m_magic = 0x1337;
#endif #endif
} }
#ifndef NDEBUG #ifdef TORRENT_DEBUG
#define CHECK_MAGIC check_magic_ cm_(m_magic) #define CHECK_MAGIC check_magic_ cm_(m_magic)
struct check_magic_ struct check_magic_
{ {

View file

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