lt sync 2994

This commit is contained in:
Andrew Resch 2008-11-29 21:53:57 +00:00
parent d7a76b3b5a
commit 403d71fdbb
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);
#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()
@ -577,7 +577,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

@ -124,7 +124,7 @@ namespace libtorrent
#else
int m_fd;
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
open_mode 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

@ -139,7 +139,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

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

View File

@ -396,7 +396,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
@ -458,7 +458,7 @@ namespace libtorrent
bool packet_finished() const
{ return m_packet_size <= m_recv_pos; }
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool piece_failed;
#endif
@ -566,7 +566,7 @@ namespace libtorrent
char m_country[2];
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
boost::intrusive_ptr<peer_connection> self()
{
TORRENT_ASSERT(!m_in_constructor);
@ -870,7 +870,7 @@ namespace libtorrent
// this is set to true once the bitfield is received
bool m_bitfield_received: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

@ -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

@ -147,7 +147,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
@ -431,7 +431,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount(index);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -447,7 +447,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount(bits);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -462,7 +462,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->inc_refcount_all();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -477,7 +477,7 @@ namespace libtorrent
TORRENT_ASSERT(!is_seed());
m_picker->dec_refcount(index);
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
else
{
TORRENT_ASSERT(is_seed());
@ -596,7 +596,7 @@ namespace libtorrent
#endif
// DEBUG
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif
@ -718,11 +718,11 @@ namespace libtorrent
// the time of next tracker announce
ptime m_next_tracker_announce;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
public:
#endif
std::set<peer_connection*> m_connections;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
private:
#endif
@ -872,7 +872,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

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

View File

@ -64,7 +64,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
@ -108,7 +108,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

@ -176,12 +176,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);
@ -216,7 +216,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

@ -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
@ -1452,7 +1452,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;
@ -1521,7 +1521,7 @@ namespace libtorrent
bitfield_string << "\n";
(*m_logger) << bitfield_string.str();
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_sent_bitfield = true;
#endif
@ -2632,7 +2632,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
@ -740,7 +740,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;
@ -857,7 +857,7 @@ namespace libtorrent
if (test_error(j))
{
ret = -1;
return;
break;
}
#ifdef TORRENT_DISK_STATS
m_log << log_time() << " read " << j.buffer_size << std::endl;

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

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

View File

@ -271,7 +271,7 @@ namespace
std::lower_bound(name_map, name_map + size
, tmp, &compare_id);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
for (int i = 1; i < size; ++i)
{
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));
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;
#endif
m_rpc.invoke(messages::find_node, addr, o);

View File

@ -239,7 +239,7 @@ namespace libtorrent { namespace dht
}
catch (std::exception& exc)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
std::cerr << "exception-type: " << typeid(exc).name() << std::endl;
std::cerr << "what: " << exc.what() << std::endl;
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));
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;
#endif
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));
#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, 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
// 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

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

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
@ -130,7 +130,7 @@ namespace libtorrent
, m_upload_only(false)
, m_snubbed(false)
, m_bitfield_received(false)
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_in_constructor(true)
, m_disconnect_started(false)
, m_initialized(false)
@ -160,7 +160,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
@ -177,7 +177,7 @@ namespace libtorrent
, tcp::endpoint const& endp
, policy::peer* peerinfo)
:
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_last_choke(time_now() - hours(1))
,
#endif
@ -237,7 +237,7 @@ namespace libtorrent
, m_upload_only(false)
, m_snubbed(false)
, m_bitfield_received(false)
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
, m_in_constructor(true)
, m_disconnect_started(false)
, m_initialized(false)
@ -272,7 +272,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);
@ -518,7 +518,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,
@ -582,7 +582,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));
@ -684,7 +684,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));
@ -862,12 +862,12 @@ namespace libtorrent
TORRENT_ASSERT(m_torrent.expired());
// check to make sure we don't have another connection with the same
// info_hash and peer_id. If we do. close this connection.
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
try
{
#endif
t->attach_peer(this);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
}
catch (std::exception& e)
{
@ -1563,7 +1563,7 @@ namespace libtorrent
m_last_piece = time_now();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
struct check_postcondition
{
check_postcondition(boost::shared_ptr<torrent> const& t_
@ -1644,7 +1644,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();
@ -1723,7 +1723,7 @@ namespace libtorrent
send_block_requests();
return;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
pending_block pending_b = *b;
#endif
@ -1821,7 +1821,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
@ -1883,7 +1883,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
@ -2248,7 +2248,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;
@ -2461,7 +2461,7 @@ namespace libtorrent
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_disconnect_started = true;
#endif
@ -2537,7 +2537,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()
@ -2761,7 +2761,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
@ -3632,7 +3632,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
@ -3816,7 +3816,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)
@ -211,7 +211,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
@ -313,7 +313,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));
@ -652,7 +652,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);
@ -785,7 +785,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);
@ -1052,7 +1052,7 @@ namespace libtorrent
c.send_block_requests();
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
bool policy::has_connection(const peer_connection* c)
{
// too expensive

View File

@ -132,7 +132,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
@ -173,7 +173,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

@ -506,7 +506,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");
@ -907,7 +907,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
@ -925,7 +925,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));
@ -1621,7 +1621,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
@ -1636,7 +1636,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)
{
@ -1660,7 +1660,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)
{
@ -1851,7 +1851,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);
@ -2503,7 +2503,7 @@ namespace aux {
#endif
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
void session_impl::check_invariant() const
{
std::set<int> unique;

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>
@ -242,7 +242,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;
@ -463,7 +463,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;
@ -484,7 +484,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;
@ -904,7 +904,7 @@ namespace libtorrent
return false;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
/*
void storage::shuffle()
{
@ -999,7 +999,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());
@ -1046,7 +1046,7 @@ namespace libtorrent
return size;
}
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
size_type in_tell = in->tell(ec);
TORRENT_ASSERT(in_tell == file_offset + file_iter->file_base && !ec);
#endif
@ -1061,7 +1061,7 @@ namespace libtorrent
size_type result = left_to_read;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int counter = 0;
#endif
@ -1073,7 +1073,7 @@ namespace libtorrent
if (read_bytes > 0)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(int(slices.size()) > counter);
size_type slice_size = slices[counter].size;
TORRENT_ASSERT(slice_size == read_bytes);
@ -1105,7 +1105,7 @@ namespace libtorrent
if (left_to_read > 0)
{
++file_iter;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
// empty files are not returned by map_block, so if
// this file was empty, don't increment the slice counter
if (read_bytes > 0) ++counter;
@ -1148,7 +1148,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());
@ -1200,7 +1200,7 @@ namespace libtorrent
TORRENT_ASSERT(left_to_write >= 0);
int buf_pos = 0;
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
int counter = 0;
#endif
while (left_to_write > 0)
@ -1239,7 +1239,7 @@ namespace libtorrent
if (left_to_write > 0)
{
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
if (write_bytes > 0) ++counter;
#endif
++file_iter;
@ -1403,7 +1403,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
@ -1574,7 +1574,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);
@ -2579,7 +2579,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..";
@ -2614,7 +2614,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
}
@ -2682,7 +2682,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

@ -295,7 +295,7 @@ namespace libtorrent
m_obfuscated_hash = h.final();
#endif
#ifndef NDEBUG
#ifdef TORRENT_DEBUG
m_files_checked = false;
#endif
INVARIANT_CHECK;
@ -1184,7 +1184,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)
{
@ -1244,7 +1244,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
@ -1266,7 +1266,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())
{
@ -1461,7 +1461,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)
{
@ -1543,7 +1543,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)
{
@ -2334,7 +2334,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
@ -2907,7 +2907,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());
@ -2930,7 +2930,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
@ -3070,12 +3070,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;
@ -3110,7 +3110,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())
@ -3545,7 +3545,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);
@ -4237,7 +4237,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);
@ -4250,7 +4250,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
}
@ -4431,7 +4431,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
{
/*