inversed TORRENT_LOGGING build config to enable logging by default. It's now disabled by TORRENT_DISABLE_LOGGING

This commit is contained in:
Arvid Norberg 2015-04-17 01:15:33 +00:00
parent a4d99188ba
commit 1faf2e201f
34 changed files with 548 additions and 587 deletions

View File

@ -190,8 +190,8 @@ else()
list(APPEND sources sha1) list(APPEND sources sha1)
endif (encryption) endif (encryption)
if (logging) if (NOT logging)
add_definitions(-DTORRENT_LOGGING) add_definitions(-DTORRENT_DISABLE_LOGGING)
endif() endif()
foreach(s ${sources}) foreach(s ${sources})

View File

@ -1,3 +1,4 @@
* enable logging build config by default (but alert mask disabled by default)
* deprecated RSS API * deprecated RSS API
* experimental support for BEP 38, "mutable torrents" * experimental support for BEP 38, "mutable torrents"
* replaced lazy_bdecode with a new bdecoder that's a lot more efficient * replaced lazy_bdecode with a new bdecoder that's a lot more efficient

View File

@ -393,8 +393,8 @@ feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
feature simulate-slow-read : off on : composite propagated ; feature simulate-slow-read : off on : composite propagated ;
feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ; feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ;
feature logging : off on : composite propagated link-incompatible ; feature logging : on off : composite propagated link-incompatible ;
feature.compose <logging>on : <define>TORRENT_LOGGING ; feature.compose <logging>off : <define>TORRENT_DISABLE_LOGGING ;
feature dht : on off logging : composite propagated link-incompatible ; feature dht : on off logging : composite propagated link-incompatible ;
feature.compose <dht>off : <define>TORRENT_DISABLE_DHT ; feature.compose <dht>off : <define>TORRENT_DISABLE_DHT ;

View File

@ -379,11 +379,11 @@ AC_MSG_CHECKING([whether logging to disk should be enabled])
AS_CASE(["$ARG_ENABLE_LOGGING"], AS_CASE(["$ARG_ENABLE_LOGGING"],
["yes"|"default"], [ ["yes"|"default"], [
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
AC_DEFINE([TORRENT_LOGGING],[1],[Define to enable support for logging alerts])
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_LOGGING "
], ],
["no"|"none"], [ ["no"|"none"], [
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
AC_DEFINE([TORRENT_DISABLE_LOGGING],[1],[Define to enable support for logging alerts])
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_DISABLE_LOGGING "
], ],
[AC_MSG_RESULT([$ARG_ENABLE_LOGGING]) [AC_MSG_RESULT([$ARG_ENABLE_LOGGING])
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_LOGGING". Use either "yes" or "no"])] AC_MSG_ERROR([Unknown option "$ARG_ENABLE_LOGGING". Use either "yes" or "no"])]

View File

@ -249,10 +249,10 @@ Build features:
| | * ``shared`` - links dynamically against the boost | | | * ``shared`` - links dynamically against the boost |
| | libraries. | | | libraries. |
+--------------------------+----------------------------------------------------+ +--------------------------+----------------------------------------------------+
| ``logging`` | * ``off`` - default. logging disabled. | | ``logging`` | * ``off`` - logging alerts disabled. |
| | * ``on`` - logging alerts available, still need to | | | * ``on`` - default. logging alerts available, |
| | be enabled by the alert mask. The reason logging | | | still need to be enabled by the alert mask. The |
| | is disabled by default is to keep the binary | | | reason to disable logging is to keep the binary |
| | size down. | | | size down. |
+--------------------------+----------------------------------------------------+ +--------------------------+----------------------------------------------------+
| ``dht`` | * ``on`` - build with support for tracker less | | ``dht`` | * ``on`` - build with support for tracker less |
@ -261,12 +261,6 @@ Build features:
| | logging of the DHT protocol traffic. | | | logging of the DHT protocol traffic. |
| | * ``off`` - build without DHT support. | | | * ``off`` - build without DHT support. |
+--------------------------+----------------------------------------------------+ +--------------------------+----------------------------------------------------+
| ``need-librt`` | * ``no`` - this platform does not need to link |
| | against librt to have POSIX time functions. |
| | * ``yes`` - specify this if your linux system |
| | requires you to link against librt.a. This is |
| | typically the case on x86 64 bit systems. |
+--------------------------+----------------------------------------------------+
| ``asserts`` | * ``auto`` - asserts are on if in debug mode | | ``asserts`` | * ``auto`` - asserts are on if in debug mode |
| | * ``on`` - asserts are on, even in release mode | | | * ``on`` - asserts are on, even in release mode |
| | * ``off`` - asserts are disabled | | | * ``off`` - asserts are disabled |
@ -356,12 +350,6 @@ Build features:
| | API. Generates build errors when deprecated | | | API. Generates build errors when deprecated |
| | functions are used. | | | functions are used. |
+--------------------------+----------------------------------------------------+ +--------------------------+----------------------------------------------------+
| ``full-stats`` | * ``on`` - default, collects stats for IP overhead |
| | and DHT and trackers. This uses a little bit |
| | extra memory for each peer and torrent. |
| | * ``off`` - only collects the standard stats for |
| | upload and download rate. |
+--------------------------+----------------------------------------------------+
| ``iconv`` | * ``auto`` - use iconv for string conversions for | | ``iconv`` | * ``auto`` - use iconv for string conversions for |
| | linux and mingw and other posix platforms. | | | linux and mingw and other posix platforms. |
| | * ``on`` - force use of iconv | | | * ``on`` - force use of iconv |
@ -371,20 +359,6 @@ Build features:
| ``i2p`` | * ``on`` - build with I2P support | | ``i2p`` | * ``on`` - build with I2P support |
| | * ``off`` - build without I2P support | | | * ``off`` - build without I2P support |
+--------------------------+----------------------------------------------------+ +--------------------------+----------------------------------------------------+
| ``boost-date-time`` | * ``off`` - don't build asio types that depend |
| | on boost.date_time. libtorrent doesn't use them |
| | but if the client does, you need these to be |
| | built. |
| | * ``on`` - build asio types that depend on |
| | boost.date_time. |
+--------------------------+----------------------------------------------------+
| ``statistics`` | * ``off`` - default. No logging of additional |
| | stats. |
| | * ``on`` - log session statistics in current |
| | working directory session_stats<pid>. The log |
| | is rotated every hour. It can be parsed by the |
| | parse_session_stats.py script (requires gnuplot) |
+--------------------------+----------------------------------------------------+
| ``profile-calls`` | * ``off`` - default. No additional call profiling. | | ``profile-calls`` | * ``off`` - default. No additional call profiling. |
| | * ``on`` - Enable logging of stack traces of | | | * ``on`` - Enable logging of stack traces of |
| | calls into libtorrent that are blocking. On | | | calls into libtorrent that are blocking. On |
@ -557,9 +531,9 @@ defines you can use to control the build.
| | compilation units having different views of | | | compilation units having different views of |
| | structs and class layouts and sizes. | | | structs and class layouts and sizes. |
+----------------------------------------+-------------------------------------------------+ +----------------------------------------+-------------------------------------------------+
| ``TORRENT_LOGGING`` | This macro will enable support for logging | | ``TORRENT_DISABLE_LOGGING`` | This macro will disable support for logging |
| | alerts, like log_alert, torrent_log_alert and | | | alerts, like log_alert, torrent_log_alert and |
| | peer_log_alert. Without this build flag, you | | | peer_log_alert. With this build flag, you |
| | cannot enable those alerts. | | | cannot enable those alerts. |
+----------------------------------------+-------------------------------------------------+ +----------------------------------------+-------------------------------------------------+
| ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant | | ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant |

View File

@ -173,21 +173,21 @@ namespace libtorrent {
rss_notification = 0x1000, rss_notification = 0x1000,
#endif #endif
// Enables debug logging alerts. These are only available when // Enables debug logging alerts. These are available unless libtorrent
// libtorrent is built with logging enabled (``TORRENT_LOGGING``). // was built with logging disabled (``TORRENT_DISABLE_LOGGING``). The
// The alerts being posted are log_alert and are session wide. // alerts being posted are log_alert and are session wide.
session_log_notification = 0x2000, session_log_notification = 0x2000,
// Enables debug logging alerts for torrents. These are only available // Enables debug logging alerts for torrents. These are available
// when libtorrent is built with logging enabled // unless libtorrent was built with logging disabled
// (``TORRENT_LOGGING``). The alerts being posted are // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are
// torrent_log_alert and are torrent wide debug events. // torrent_log_alert and are torrent wide debug events.
torrent_log_notification = 0x4000, torrent_log_notification = 0x4000,
// Enables debug logging alerts for peers. These are only available // Enables debug logging alerts for peers. These are available unless
// when libtorrent is built with logging enabled // libtorrent was built with logging disabled
// (``TORRENT_LOGGING``). The alerts being posted are peer_log_alert // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are
// and low-level peer events and messages. // peer_log_alert and low-level peer events and messages.
peer_log_notification = 0x8000, peer_log_notification = 0x8000,
// The full bitmask, representing all available categories. // The full bitmask, representing all available categories.

View File

@ -2118,9 +2118,7 @@ namespace libtorrent
// This alert is posted by some session wide event. Its main purpose is // This alert is posted by some session wide event. Its main purpose is
// trouble shooting and debugging. It's not enabled by the default alert // trouble shooting and debugging. It's not enabled by the default alert
// mask and is enabled by the ``alert::session_log_notification`` bit. // mask and is enabled by the ``alert::session_log_notification`` bit.
// Furhtermore, it's by default disabled as a build configuration. To // Furhtermore, it's by default disabled as a build configuration.
// enable, build libtorrent with logging support enabled (``logging=on``
// with bjam or define ``TORRENT_LOGGING``).
struct TORRENT_EXPORT log_alert : alert struct TORRENT_EXPORT log_alert : alert
{ {
// internal // internal
@ -2142,9 +2140,7 @@ namespace libtorrent
// This alert is posted by torrent wide events. It's meant to be used for // This alert is posted by torrent wide events. It's meant to be used for
// trouble shooting and debugging. It's not enabled by the default alert // trouble shooting and debugging. It's not enabled by the default alert
// mask and is enabled by the ``alert::torrent_log_notification`` bit. By // mask and is enabled by the ``alert::torrent_log_notification`` bit. By
// default it is disabled as a build configuration. To enable, build // default it is disabled as a build configuration.
// libtorrent with logging support enabled (``logging=on`` with bjam or
// define ``TORRENT_LOGGING``).
struct TORRENT_EXPORT torrent_log_alert : torrent_alert struct TORRENT_EXPORT torrent_log_alert : torrent_alert
{ {
// internal // internal
@ -2166,9 +2162,7 @@ namespace libtorrent
// This alert is posted by events specific to a peer. It's meant to be used // This alert is posted by events specific to a peer. It's meant to be used
// for trouble shooting and debugging. It's not enabled by the default alert // for trouble shooting and debugging. It's not enabled by the default alert
// mask and is enabled by the ``alert::peer_log_notification`` bit. By // mask and is enabled by the ``alert::peer_log_notification`` bit. By
// default it is disabled as a build configuration. To enable, build // default it is disabled as a build configuration.
// libtorrent with logging support enabled (``logging=on`` with bjam or
// define ``TORRENT_LOGGING``).
struct TORRENT_EXPORT peer_log_alert : peer_alert struct TORRENT_EXPORT peer_log_alert : peer_alert
{ {
// internal // internal

View File

@ -152,7 +152,7 @@ namespace libtorrent
struct session_impl; struct session_impl;
struct session_settings; struct session_settings;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
struct tracker_logger; struct tracker_logger;
#endif #endif
@ -350,7 +350,7 @@ namespace libtorrent
void on_port_map_log(char const* msg, int map_transport); void on_port_map_log(char const* msg, int map_transport);
void on_lsd_announce(error_code const& e); void on_lsd_announce(error_code const& e);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
void on_lsd_log(char const* log); void on_lsd_log(char const* log);
#endif #endif
@ -1131,7 +1131,7 @@ namespace libtorrent
// accumulated error // accumulated error
boost::uint16_t m_tick_residual; boost::uint16_t m_tick_residual;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
virtual void session_log(char const* fmt, ...) const; virtual void session_log(char const* fmt, ...) const;
virtual void session_vlog(char const* fmt, va_list& va) const; virtual void session_vlog(char const* fmt, va_list& va) const;
@ -1203,7 +1203,7 @@ namespace libtorrent
#endif #endif
}; };
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
struct tracker_logger : request_callback struct tracker_logger : request_callback
{ {
tracker_logger(session_interface& ses); tracker_logger(session_interface& ses);

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#endif #endif
@ -97,13 +97,13 @@ namespace libtorrent
namespace libtorrent { namespace aux namespace libtorrent { namespace aux
{ {
#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
// This is the basic logging and debug interface offered by the session. // This is the basic logging and debug interface offered by the session.
// a release build with logging disabled (which is the default) will // a release build with logging disabled (which is the default) will
// not have this class at all // not have this class at all
struct session_logger struct session_logger
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
virtual void session_log(char const* fmt, ...) const = 0; virtual void session_log(char const* fmt, ...) const = 0;
virtual void session_vlog(char const* fmt, va_list& va) const = 0; virtual void session_vlog(char const* fmt, va_list& va) const = 0;
#endif #endif
@ -115,14 +115,14 @@ namespace libtorrent { namespace aux
virtual bool is_posting_torrent_updates() const = 0; virtual bool is_posting_torrent_updates() const = 0;
#endif #endif
}; };
#endif // TORRENT_LOGGING || TORRENT_USE_ASSERTS #endif // TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
// TOOD: 2 make this interface a lot smaller. It could be split up into // TOOD: 2 make this interface a lot smaller. It could be split up into
// several smaller interfaces. Each subsystem could then limit the size // several smaller interfaces. Each subsystem could then limit the size
// of the mock object to test it. // of the mock object to test it.
struct session_interface struct session_interface
: buffer_allocator_interface : buffer_allocator_interface
#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, session_logger , session_logger
#endif #endif
{ {

View File

@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include <boost/function/function1.hpp> #include <boost/function/function1.hpp>
#endif #endif
@ -51,7 +51,7 @@ namespace libtorrent
{ {
typedef boost::function<void(tcp::endpoint, sha1_hash)> peer_callback_t; typedef boost::function<void(tcp::endpoint, sha1_hash)> peer_callback_t;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
typedef boost::function<void(char const*)> log_callback_t; typedef boost::function<void(char const*)> log_callback_t;
#endif #endif
@ -59,7 +59,7 @@ class lsd : public boost::enable_shared_from_this<lsd>
{ {
public: public:
lsd(io_service& ios, peer_callback_t const& cb lsd(io_service& ios, peer_callback_t const& cb
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
, log_callback_t const& log , log_callback_t const& log
#endif #endif
); );
@ -89,7 +89,7 @@ private:
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
broadcast_socket m_socket6; broadcast_socket m_socket6;
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_callback_t m_log_cb; log_callback_t m_log_cb;
void debug_log(char const* fmt, ...) const; void debug_log(char const* fmt, ...) const;
#endif #endif

View File

@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector> #include <vector>
#include <string> #include <string>
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/debug.hpp" #include "libtorrent/debug.hpp"
#endif #endif
@ -414,7 +414,7 @@ namespace libtorrent
void set_holepunch_mode() void set_holepunch_mode()
{ {
m_holepunch_mode = true; m_holepunch_mode = true;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** HOLEPUNCH MODE ***"); peer_log("*** HOLEPUNCH MODE ***");
#endif #endif
} }
@ -550,11 +550,11 @@ namespace libtorrent
void decrease_est_reciprocation_rate(); void decrease_est_reciprocation_rate();
int est_reciprocation_rate() const { return m_est_reciprocation_rate; } int est_reciprocation_rate() const { return m_est_reciprocation_rate; }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
virtual void peer_log(char const* fmt, ...) const; virtual void peer_log(char const* fmt, ...) const;
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
time_point m_connect_time; time_point m_connect_time;
time_point m_bitfield_time; time_point m_bitfield_time;
time_point m_unchoke_time; time_point m_unchoke_time;
@ -650,7 +650,7 @@ namespace libtorrent
virtual boost::optional<piece_block_progress> virtual boost::optional<piece_block_progress>
downloading_piece_progress() const downloading_piece_progress() const
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** downloading_piece_progress() dispatched to the base class!"); peer_log("*** downloading_piece_progress() dispatched to the base class!");
#endif #endif
return boost::optional<piece_block_progress>(); return boost::optional<piece_block_progress>();

View File

@ -62,7 +62,7 @@ namespace libtorrent
virtual bool failed() const = 0; virtual bool failed() const = 0;
virtual stat const& statistics() const = 0; virtual stat const& statistics() const = 0;
virtual void get_peer_info(peer_info& p) const = 0; virtual void get_peer_info(peer_info& p) const = 0;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
virtual void peer_log(char const* fmt, ...) const = 0; virtual void peer_log(char const* fmt, ...) const = 0;
#endif #endif
}; };

View File

@ -1025,7 +1025,7 @@ namespace libtorrent
time_t last_seen_complete() const { return m_last_seen_complete; } time_t last_seen_complete() const { return m_last_seen_complete; }
// LOGGING // LOGGING
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
virtual void debug_log(const char* fmt, ...) const; virtual void debug_log(const char* fmt, ...) const;
void log_to_all_peers(char const* message); void log_to_all_peers(char const* message);
time_point m_dht_start_time; time_point m_dht_start_time;

View File

@ -230,7 +230,7 @@ namespace libtorrent
, const std::string& msg , const std::string& msg
, int retry_interval) = 0; , int retry_interval) = 0;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
virtual void debug_log(const char* fmt, ...) const = 0; virtual void debug_log(const char* fmt, ...) const = 0;
#endif #endif
}; };
@ -336,7 +336,7 @@ namespace libtorrent
, resolver_interface& resolver , resolver_interface& resolver
, struct ip_filter& ipf , struct ip_filter& ipf
, aux::session_settings const& sett , aux::session_settings const& sett
#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, aux::session_logger& ses , aux::session_logger& ses
#endif #endif
); );
@ -392,7 +392,7 @@ namespace libtorrent
resolver_interface& m_host_resolver; resolver_interface& m_host_resolver;
aux::session_settings const& m_settings; aux::session_settings const& m_settings;
counters& m_stats_counters; counters& m_stats_counters;
#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
aux::session_logger& m_ses; aux::session_logger& m_ses;
#endif #endif

View File

@ -161,10 +161,6 @@ void utp_send_ack(utp_socket_impl* s);
void utp_socket_drained(utp_socket_impl* s); void utp_socket_drained(utp_socket_impl* s);
void utp_writable(utp_socket_impl* s); void utp_writable(utp_socket_impl* s);
#if defined TORRENT_LOGGING
int socket_impl_size();
#endif
// this is the user-level stream interface to utp sockets. // this is the user-level stream interface to utp sockets.
// the reason why it's split up in a utp_stream class and // the reason why it's split up in a utp_stream class and
// an implementation class is because the socket state has // an implementation class is because the socket state has

View File

@ -125,7 +125,7 @@ namespace libtorrent
, m_in_constructor(true) , m_in_constructor(true)
#endif #endif
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** bt_peer_connection"); peer_log("*** bt_peer_connection");
#endif #endif
@ -173,7 +173,7 @@ namespace libtorrent
if (t->graceful_pause()) if (t->graceful_pause())
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** ON_CONNECTED [ graceful-paused ]"); peer_log("*** ON_CONNECTED [ graceful-paused ]");
#endif #endif
disconnect(error_code(errors::torrent_paused), op_bittorrent); disconnect(error_code(errors::torrent_paused), op_bittorrent);
@ -193,7 +193,7 @@ namespace libtorrent
if (is_ssl(*get_socket())) if (is_ssl(*get_socket()))
out_enc_policy = settings_pack::pe_disabled; out_enc_policy = settings_pack::pe_disabled;
#endif #endif
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char const* policy_name[] = {"forced", "enabled", "disabled"}; char const* policy_name[] = {"forced", "enabled", "disabled"};
peer_log("*** outgoing encryption policy: %s", policy_name[out_enc_policy]); peer_log("*** outgoing encryption policy: %s", policy_name[out_enc_policy]);
#endif #endif
@ -254,7 +254,7 @@ namespace libtorrent
void bt_peer_connection::on_metadata() void bt_peer_connection::on_metadata()
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** ON_METADATA"); peer_log("*** ON_METADATA");
#endif #endif
@ -286,7 +286,7 @@ namespace libtorrent
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield); TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> DHT_PORT [ %d ]", listen_port); peer_log("==> DHT_PORT [ %d ]", listen_port);
#endif #endif
char msg[] = {0,0,0,3, msg_dht_port, 0, 0}; char msg[] = {0,0,0,3, msg_dht_port, 0, 0};
@ -302,7 +302,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake); TORRENT_ASSERT(m_sent_handshake);
m_sent_bitfield = true; m_sent_bitfield = true;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> HAVE_ALL"); peer_log("==> HAVE_ALL");
#endif #endif
char msg[] = {0,0,0,1, msg_have_all}; char msg[] = {0,0,0,1, msg_have_all};
@ -316,7 +316,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake); TORRENT_ASSERT(m_sent_handshake);
m_sent_bitfield = true; m_sent_bitfield = true;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> HAVE_NONE"); peer_log("==> HAVE_NONE");
#endif #endif
char msg[] = {0,0,0,1, msg_have_none}; char msg[] = {0,0,0,1, msg_have_none};
@ -333,7 +333,7 @@ namespace libtorrent
if (!m_supports_fast) return; if (!m_supports_fast) return;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]" peer_log("==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]"
, r.piece, r.start, r.length); , r.piece, r.start, r.length);
#endif #endif
@ -379,7 +379,7 @@ namespace libtorrent
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> SUGGEST [ piece: %d num_peers: %d ]", piece peer_log("==> SUGGEST [ piece: %d num_peers: %d ]", piece
, t->has_picker() ? t->picker().get_availability(piece) : -1); , t->has_picker() ? t->picker().get_availability(piece) : -1);
#endif #endif
@ -444,7 +444,7 @@ namespace libtorrent
TORRENT_ASSERT(!m_dh_key_exchange.get()); TORRENT_ASSERT(!m_dh_key_exchange.get());
TORRENT_ASSERT(!m_sent_handshake); TORRENT_ASSERT(!m_sent_handshake);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (is_outgoing()) if (is_outgoing())
peer_log("*** initiating encrypted handshake"); peer_log("*** initiating encrypted handshake");
#endif #endif
@ -458,7 +458,7 @@ namespace libtorrent
int pad_size = random() % 512; int pad_size = random() % 512;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(" pad size: %d", pad_size); peer_log(" pad size: %d", pad_size);
#endif #endif
@ -472,7 +472,7 @@ namespace libtorrent
std::generate(ptr, ptr + pad_size, random_byte); std::generate(ptr, ptr + pad_size, random_byte);
send_buffer(msg, buf_size); send_buffer(msg, buf_size);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(" sent DH key"); peer_log(" sent DH key");
#endif #endif
} }
@ -536,7 +536,7 @@ namespace libtorrent
if ((crypto_provide & settings_pack::pe_both) == 0) if ((crypto_provide & settings_pack::pe_both) == 0)
crypto_provide = settings_pack::pe_both; crypto_provide = settings_pack::pe_both;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char const* level[] = {"plaintext", "rc4", "plaintext rc4"}; char const* level[] = {"plaintext", "rc4", "plaintext rc4"};
peer_log(" crypto provide : [ %s ]" peer_log(" crypto provide : [ %s ]"
, level[crypto_provide-1]); , level[crypto_provide-1]);
@ -576,7 +576,7 @@ namespace libtorrent
else // 0x01 else // 0x01
m_rc4_encrypted = false; m_rc4_encrypted = false;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(" crypto select : [ %s ]" peer_log(" crypto select : [ %s ]"
, (crypto_select == 0x01) ? "plaintext" : "rc4"); , (crypto_select == 0x01) ? "plaintext" : "rc4");
#endif #endif
@ -654,7 +654,7 @@ namespace libtorrent
m_rc4->set_incoming_key(&remote_key[0], 20); m_rc4->set_incoming_key(&remote_key[0], 20);
m_rc4->set_outgoing_key(&local_key[0], 20); m_rc4->set_outgoing_key(&local_key[0], 20);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(" computed RC4 keys"); peer_log(" computed RC4 keys");
#endif #endif
} }
@ -786,7 +786,7 @@ namespace libtorrent
// we support FAST extension // we support FAST extension
*(ptr + 7) |= 0x04; *(ptr + 7) |= 0x04;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::string bitmask; std::string bitmask;
for (int k = 0; k < 8; ++k) for (int k = 0; k < 8; ++k)
{ {
@ -817,7 +817,7 @@ namespace libtorrent
memcpy(ptr, &m_our_peer_id[0], 20); memcpy(ptr, &m_our_peer_id[0], 20);
ptr += 20; ptr += 20;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
{ {
char hex_pid[41]; char hex_pid[41];
to_hex((char const*)&m_our_peer_id[0], 20, hex_pid); to_hex((char const*)&m_our_peer_id[0], 20, hex_pid);
@ -900,7 +900,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== KEEPALIVE"); peer_log("<== KEEPALIVE");
#endif #endif
incoming_keepalive(); incoming_keepalive();
@ -1240,7 +1240,7 @@ namespace libtorrent
if (recv_pos < header_size) return; if (recv_pos < header_size) return;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
// peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d" // peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d"
// , p.piece, p.start, p.length); // , p.piece, p.start, p.length);
#endif #endif
@ -1260,7 +1260,7 @@ namespace libtorrent
if (merkle && list_size > 0) if (merkle && list_size > 0)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size); peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size);
#endif #endif
bdecode_node hash_list; bdecode_node hash_list;
@ -1511,7 +1511,7 @@ namespace libtorrent
#endif #endif
else else
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
error_code ec; error_code ec;
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"}; static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]" peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]"
@ -1529,7 +1529,7 @@ namespace libtorrent
{ {
case hp_rendezvous: // rendezvous case hp_rendezvous: // rendezvous
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]" peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]"
, print_address(ep.address()).c_str()); , print_address(ep.address()).c_str());
#endif #endif
@ -1563,7 +1563,7 @@ namespace libtorrent
torrent_peer* p = t->add_peer(ep, peer_info::pex); torrent_peer* p = t->add_peer(ep, peer_info::pex);
if (p == 0 || p->connection) if (p == 0 || p->connection)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: failed to add peer ]" peer_log("<== HOLEPUNCH [ msg:connect to: %s error: failed to add peer ]"
, print_address(ep.address()).c_str()); , print_address(ep.address()).c_str());
#endif #endif
@ -1573,7 +1573,7 @@ namespace libtorrent
} }
if (p->banned) if (p->banned)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]" peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]"
, print_address(ep.address()).c_str()); , print_address(ep.address()).c_str());
#endif #endif
@ -1592,7 +1592,7 @@ namespace libtorrent
t->update_want_peers(); t->update_want_peers();
if (p->connection) if (p->connection)
p->connection->set_holepunch_mode(); p->connection->set_holepunch_mode();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== HOLEPUNCH [ msg:connect to: %s ]" peer_log("<== HOLEPUNCH [ msg:connect to: %s ]"
, print_address(ep.address()).c_str()); , print_address(ep.address()).c_str());
#endif #endif
@ -1600,7 +1600,7 @@ namespace libtorrent
case hp_failed: case hp_failed:
{ {
boost::uint32_t error = detail::read_uint32(ptr); boost::uint32_t error = detail::read_uint32(ptr);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
error_code ec; error_code ec;
char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"}; char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"};
peer_log("<== HOLEPUNCH [ msg:failed error: %d msg: %s ]", error peer_log("<== HOLEPUNCH [ msg:failed error: %d msg: %s ]", error
@ -1609,7 +1609,7 @@ namespace libtorrent
// #error deal with holepunch errors // #error deal with holepunch errors
(void)error; (void)error;
} break; } break;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
default: default:
{ {
error_code ec; error_code ec;
@ -1629,7 +1629,7 @@ namespace libtorrent
else detail::write_uint8(1, ptr); else detail::write_uint8(1, ptr);
detail::write_endpoint(ep, ptr); detail::write_endpoint(ep, ptr);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
error_code ec; error_code ec;
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"}; static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
static const char* hp_error_string[] = {"", "no such peer", "not connected", "no support", "no self"}; static const char* hp_error_string[] = {"", "no such peer", "not connected", "no support", "no self"};
@ -1700,13 +1700,13 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return; if (!m_recv_buffer.packet_finished()) return;
if (m_recv_buffer.packet_size() != 3) if (m_recv_buffer.packet_size() != 3)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== UPLOAD_ONLY [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size()); peer_log("<== UPLOAD_ONLY [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
#endif #endif
return; return;
} }
bool ul = detail::read_uint8(recv_buffer.begin) != 0; bool ul = detail::read_uint8(recv_buffer.begin) != 0;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false")); peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false"));
#endif #endif
set_upload_only(ul); set_upload_only(ul);
@ -1718,13 +1718,13 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return; if (!m_recv_buffer.packet_finished()) return;
if (m_recv_buffer.packet_size() != 3) if (m_recv_buffer.packet_size() != 3)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== SHARE_MODE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size()); peer_log("<== SHARE_MODE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
#endif #endif
return; return;
} }
bool sm = detail::read_uint8(recv_buffer.begin) != 0; bool sm = detail::read_uint8(recv_buffer.begin) != 0;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== SHARE_MODE [ %s ]", (sm?"true":"false")); peer_log("<== SHARE_MODE [ %s ]", (sm?"true":"false"));
#endif #endif
set_share_mode(sm); set_share_mode(sm);
@ -1734,7 +1734,7 @@ namespace libtorrent
if (extended_id == holepunch_msg) if (extended_id == holepunch_msg)
{ {
if (!m_recv_buffer.packet_finished()) return; if (!m_recv_buffer.packet_finished()) return;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== HOLEPUNCH"); peer_log("<== HOLEPUNCH");
#endif #endif
on_holepunch(); on_holepunch();
@ -1746,7 +1746,7 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return; if (!m_recv_buffer.packet_finished()) return;
if (m_recv_buffer.packet_size() != 6) if (m_recv_buffer.packet_size() != 6)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== DONT_HAVE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size()); peer_log("<== DONT_HAVE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
#endif #endif
return; return;
@ -1756,7 +1756,7 @@ namespace libtorrent
return; return;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (m_recv_buffer.packet_finished()) if (m_recv_buffer.packet_finished())
peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]" peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]"
, extended_id, m_recv_buffer.packet_size()); , extended_id, m_recv_buffer.packet_size());
@ -1789,14 +1789,14 @@ namespace libtorrent
int ret = bdecode(recv_buffer.begin + 2, recv_buffer.end, root, ec, &pos); int ret = bdecode(recv_buffer.begin + 2, recv_buffer.end, root, ec, &pos);
if (ret != 0 || ec || root.type() != bdecode_node::dict_t) if (ret != 0 || ec || root.type() != bdecode_node::dict_t)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** invalid extended handshake: %s pos: %d" peer_log("*** invalid extended handshake: %s pos: %d"
, ec.message().c_str(), pos); , ec.message().c_str(), pos);
#endif #endif
return; return;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str()); peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str());
#endif #endif
@ -1981,7 +1981,7 @@ namespace libtorrent
// connections, don't sent upload-only // connections, don't sent upload-only
if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return; if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> UPLOAD_ONLY [ %d ]" peer_log("==> UPLOAD_ONLY [ %d ]"
, int(t->is_upload_only() && !t->super_seeding())); , int(t->is_upload_only() && !t->super_seeding()));
#endif #endif
@ -2082,7 +2082,7 @@ namespace libtorrent
if (t->super_seeding()) if (t->super_seeding())
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(" *** NOT SENDING BITFIELD, super seeding"); peer_log(" *** NOT SENDING BITFIELD, super seeding");
#endif #endif
if (m_supports_fast) write_have_none(); if (m_supports_fast) write_have_none();
@ -2113,7 +2113,7 @@ namespace libtorrent
else if (t->num_have() == 0) else if (t->num_have() == 0)
{ {
// don't send a bitfield if we don't have any pieces // don't send a bitfield if we don't have any pieces
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(" *** NOT SENDING BITFIELD"); peer_log(" *** NOT SENDING BITFIELD");
#endif #endif
m_sent_bitfield = true; m_sent_bitfield = true;
@ -2184,7 +2184,7 @@ namespace libtorrent
, end(t->predictive_pieces().end()); i != end; ++i) , end(t->predictive_pieces().end()); i != end; ++i)
msg[5 + *i / 8] |= (0x80 >> (*i & 7)); msg[5 + *i / 8] |= (0x80 >> (*i & 7));
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::string bitfield_string; std::string bitfield_string;
bitfield_string.resize(num_pieces); bitfield_string.resize(num_pieces);
@ -2205,7 +2205,7 @@ namespace libtorrent
{ {
for (int i = 0; i < num_lazy_pieces; ++i) for (int i = 0; i < num_lazy_pieces; ++i)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]); peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]);
#endif #endif
write_have(lazy_pieces[i]); write_have(lazy_pieces[i]);
@ -2324,7 +2324,7 @@ namespace libtorrent
stats_counters().inc_stats_counter(counters::num_outgoing_ext_handshake); stats_counters().inc_stats_counter(counters::num_outgoing_ext_handshake);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str()); peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str());
#endif #endif
} }
@ -2538,7 +2538,7 @@ namespace libtorrent
if (!m_enc_handler.is_recv_plaintext()) if (!m_enc_handler.is_recv_plaintext())
{ {
int consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred); int consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (consumed + bytes_transferred > 0) if (consumed + bytes_transferred > 0)
peer_log("<== decrypted block [ s = %d ]", consumed + bytes_transferred); peer_log("<== decrypted block [ s = %d ]", consumed + bytes_transferred);
#endif #endif
@ -2610,7 +2610,7 @@ namespace libtorrent
return; return;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** received DH key"); peer_log("*** received DH key");
#endif #endif
@ -2709,7 +2709,7 @@ namespace libtorrent
else else
{ {
std::size_t bytes_processed = syncoffset + 20; std::size_t bytes_processed = syncoffset + 20;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** sync point (hash) found at offset %d" peer_log("*** sync point (hash) found at offset %d"
, m_sync_bytes_read + bytes_processed - 20); , m_sync_bytes_read + bytes_processed - 20);
#endif #endif
@ -2758,7 +2758,7 @@ namespace libtorrent
} }
init_pe_rc4_handler(m_dh_key_exchange->get_secret(), ti->info_hash()); init_pe_rc4_handler(m_dh_key_exchange->get_secret(), ti->info_hash());
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** stream key found, torrent located"); peer_log("*** stream key found, torrent located");
#endif #endif
} }
@ -2781,7 +2781,7 @@ namespace libtorrent
return; return;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** verification constant found"); peer_log("*** verification constant found");
#endif #endif
m_state = read_pe_cryptofield; m_state = read_pe_cryptofield;
@ -2845,7 +2845,7 @@ namespace libtorrent
else else
{ {
std::size_t bytes_processed = syncoffset + 8; std::size_t bytes_processed = syncoffset + 8;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** sync point (verification constant) found at offset %d" peer_log("*** sync point (verification constant) found at offset %d"
, m_sync_bytes_read + bytes_processed - 8); , m_sync_bytes_read + bytes_processed - 8);
#endif #endif
@ -2880,7 +2880,7 @@ namespace libtorrent
boost::uint32_t crypto_field = detail::read_uint32(recv_buffer.begin); boost::uint32_t crypto_field = detail::read_uint32(recv_buffer.begin);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** crypto %s : [%s%s ]" peer_log("*** crypto %s : [%s%s ]"
, is_outgoing() ? "select" : "provide" , is_outgoing() ? "select" : "provide"
, (crypto_field & 1) ? " plaintext" : "" , (crypto_field & 1) ? " plaintext" : ""
@ -2994,7 +2994,7 @@ namespace libtorrent
return; return;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** len(IA) : %d", len_ia); peer_log("*** len(IA) : %d", len_ia);
#endif #endif
if (len_ia == 0) if (len_ia == 0)
@ -3040,7 +3040,7 @@ namespace libtorrent
buffer::interval wr_buf = m_recv_buffer.mutable_buffer(); buffer::interval wr_buf = m_recv_buffer.mutable_buffer();
rc4_decrypt(wr_buf.begin, m_recv_buffer.packet_size()); rc4_decrypt(wr_buf.begin, m_recv_buffer.packet_size());
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** decrypted ia : %d bytes", m_recv_buffer.packet_size()); peer_log("*** decrypted ia : %d bytes", m_recv_buffer.packet_size());
#endif #endif
@ -3089,7 +3089,7 @@ namespace libtorrent
wr_buf.begin += m_recv_buffer.packet_size(); wr_buf.begin += m_recv_buffer.packet_size();
rc4_decrypt(wr_buf.begin, wr_buf.left()); rc4_decrypt(wr_buf.begin, wr_buf.left());
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** decrypted remaining %d bytes", wr_buf.left()); peer_log("*** decrypted remaining %d bytes", wr_buf.left());
#endif #endif
} }
@ -3130,14 +3130,14 @@ namespace libtorrent
memcmp(recv_buffer.begin, protocol_string, 20) != 0) memcmp(recv_buffer.begin, protocol_string, 20) != 0)
{ {
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** unrecognized protocol header"); peer_log("*** unrecognized protocol header");
#endif #endif
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
if (is_ssl(*get_socket())) if (is_ssl(*get_socket()))
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** SSL peers are not allowed to use any other encryption"); peer_log("*** SSL peers are not allowed to use any other encryption");
#endif #endif
disconnect(errors::invalid_info_hash, op_bittorrent, 1); disconnect(errors::invalid_info_hash, op_bittorrent, 1);
@ -3163,7 +3163,7 @@ namespace libtorrent
return; return;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** attempting encrypted connection"); peer_log("*** attempting encrypted connection");
#endif #endif
m_state = read_pe_dhkey; m_state = read_pe_dhkey;
@ -3191,7 +3191,7 @@ namespace libtorrent
} }
#endif #endif
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== BitTorrent protocol"); peer_log("<== BitTorrent protocol");
#endif #endif
} }
@ -3211,7 +3211,7 @@ namespace libtorrent
recv_buffer = m_recv_buffer.get(); recv_buffer = m_recv_buffer.get();
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::string extensions; std::string extensions;
extensions.resize(8 * 8); extensions.resize(8 * 8);
for (int i=0; i < 8; ++i) for (int i=0; i < 8; ++i)
@ -3267,14 +3267,14 @@ namespace libtorrent
if (!std::equal(recv_buffer.begin + 8, recv_buffer.begin + 28 if (!std::equal(recv_buffer.begin + 8, recv_buffer.begin + 28
, (const char*)t->torrent_file().info_hash().begin())) , (const char*)t->torrent_file().info_hash().begin()))
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** received invalid info_hash"); peer_log("*** received invalid info_hash");
#endif #endif
disconnect(errors::invalid_info_hash, op_bittorrent, 1); disconnect(errors::invalid_info_hash, op_bittorrent, 1);
return; return;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<<< info_hash received"); peer_log("<<< info_hash received");
#endif #endif
} }
@ -3310,7 +3310,7 @@ namespace libtorrent
if (!m_recv_buffer.packet_finished()) return; if (!m_recv_buffer.packet_finished()) return;
recv_buffer = m_recv_buffer.get(); recv_buffer = m_recv_buffer.get();
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
{ {
char hex_pid[41]; char hex_pid[41];
to_hex(recv_buffer.begin, 20, hex_pid); to_hex(recv_buffer.begin, 20, hex_pid);
@ -3392,7 +3392,7 @@ namespace libtorrent
if (m_supports_extensions) write_extensions(); if (m_supports_extensions) write_extensions();
#endif #endif
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== HANDSHAKE"); peer_log("<== HANDSHAKE");
#endif #endif
// consider this a successful connection, reset the failcount // consider this a successful connection, reset the failcount
@ -3508,7 +3508,7 @@ namespace libtorrent
int bt_peer_connection::hit_send_barrier(std::vector<asio::mutable_buffer>& iovec) int bt_peer_connection::hit_send_barrier(std::vector<asio::mutable_buffer>& iovec)
{ {
int next_barrier = m_enc_handler.encrypt(iovec); int next_barrier = m_enc_handler.encrypt(iovec);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (next_barrier != 0) if (next_barrier != 0)
peer_log("==> encrypted block [ s = %d ]", next_barrier); peer_log("==> encrypted block [ s = %d ]", next_barrier);
#endif #endif

View File

@ -78,7 +78,7 @@ namespace libtorrent
prefer_contiguous_blocks(blocks_per_piece); prefer_contiguous_blocks(blocks_per_piece);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** http_seed_connection"); peer_log("*** http_seed_connection");
#endif #endif
} }
@ -194,7 +194,7 @@ namespace libtorrent
request += "\r\n\r\n"; request += "\r\n\r\n";
m_first_request = false; m_first_request = false;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> %s", request.c_str()); peer_log("==> %s", request.c_str());
#endif #endif
@ -213,7 +213,7 @@ namespace libtorrent
if (error) if (error)
{ {
received_bytes(0, bytes_transferred); received_bytes(0, bytes_transferred);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** http_seed_connection error: %s", error.message().c_str()); peer_log("*** http_seed_connection error: %s", error.message().c_str());
#endif #endif
return; return;
@ -375,7 +375,7 @@ namespace libtorrent
} }
else else
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size); peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
#endif #endif
TORRENT_ASSERT(bytes_transferred >= size_t(header_size - m_partial_chunk_header)); TORRENT_ASSERT(bytes_transferred >= size_t(header_size - m_partial_chunk_header));
@ -413,7 +413,7 @@ namespace libtorrent
int retry_time = atol(std::string(recv_buffer.begin, recv_buffer.end).c_str()); int retry_time = atol(std::string(recv_buffer.begin, recv_buffer.end).c_str());
if (retry_time <= 0) retry_time = 60; if (retry_time <= 0) retry_time = 60;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** retrying in %d seconds", retry_time); peer_log("*** retrying in %d seconds", retry_time);
#endif #endif

View File

@ -232,7 +232,7 @@ namespace libtorrent
// the url + 100 estimated header size // the url + 100 estimated header size
sent_bytes(url.size() + 100); sent_bytes(url.size() + 100);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
if (cb) if (cb)
@ -266,7 +266,7 @@ namespace libtorrent
++i; ++i;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
if (cb) if (cb)
{ {

View File

@ -66,7 +66,7 @@ namespace libtorrent
static error_code ec; static error_code ec;
lsd::lsd(io_service& ios, peer_callback_t const& cb lsd::lsd(io_service& ios, peer_callback_t const& cb
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
, log_callback_t const& log , log_callback_t const& log
#endif #endif
) )
@ -75,7 +75,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
, m_socket6(udp::endpoint(address_v6::from_string("ff15::efc0:988f", ec), 6771)) , m_socket6(udp::endpoint(address_v6::from_string("ff15::efc0:988f", ec), 6771))
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
, m_log_cb(log) , m_log_cb(log)
#endif #endif
, m_broadcast_timer(ios) , m_broadcast_timer(ios)
@ -87,7 +87,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb
{ {
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
void lsd::debug_log(char const* fmt, ...) const void lsd::debug_log(char const* fmt, ...) const
{ {
va_list v; va_list v;
@ -144,7 +144,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
to_hex((char const*)&ih[0], 20, ih_hex); to_hex((char const*)&ih[0], 20, ih_hex);
char msg[200]; char msg[200];
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("==> LSD: ih: %s port: %u\n", ih_hex, listen_port); debug_log("==> LSD: ih: %s port: %u\n", ih_hex, listen_port);
#endif #endif
@ -157,7 +157,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
if (ec) if (ec)
{ {
m_disabled = true; m_disabled = true;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** LSD: failed to send message: (%d) %s", ec.value() debug_log("*** LSD: failed to send message: (%d) %s", ec.value()
, ec.message().c_str()); , ec.message().c_str());
#endif #endif
@ -173,7 +173,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
if (ec) if (ec)
{ {
m_disabled6 = true; m_disabled6 = true;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** LSD: failed to send message6: (%d) %s", ec.value() debug_log("*** LSD: failed to send message6: (%d) %s", ec.value()
, ec.message().c_str()); , ec.message().c_str());
#endif #endif
@ -222,7 +222,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
if (!p.header_finished() || error) if (!p.header_finished() || error)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("<== LSD: incomplete HTTP message"); debug_log("<== LSD: incomplete HTTP message");
#endif #endif
return; return;
@ -230,7 +230,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
if (p.method() != "bt-search") if (p.method() != "bt-search")
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("<== LSD: invalid HTTP method: %s", p.method().c_str()); debug_log("<== LSD: invalid HTTP method: %s", p.method().c_str());
#endif #endif
return; return;
@ -239,7 +239,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
std::string const& port_str = p.header("port"); std::string const& port_str = p.header("port");
if (port_str.empty()) if (port_str.empty())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("<== LSD: invalid BT-SEARCH, missing port"); debug_log("<== LSD: invalid BT-SEARCH, missing port");
#endif #endif
return; return;
@ -258,7 +258,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
boost::int32_t cookie = strtol(cookie_iter->second.c_str(), NULL, 16); boost::int32_t cookie = strtol(cookie_iter->second.c_str(), NULL, 16);
if (cookie == m_cookie) if (cookie == m_cookie)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("<== LSD: ignoring packet (cookie matched our own): %x == %x" debug_log("<== LSD: ignoring packet (cookie matched our own): %x == %x"
, cookie, m_cookie); , cookie, m_cookie);
#endif #endif
@ -274,7 +274,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
std::string const& ih_str = i->second; std::string const& ih_str = i->second;
if (ih_str.size() != 40) if (ih_str.size() != 40)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("<== LSD: invalid BT-SEARCH, invalid infohash: %s" debug_log("<== LSD: invalid BT-SEARCH, invalid infohash: %s"
, ih_str.c_str()); , ih_str.c_str());
#endif #endif
@ -286,7 +286,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
if (!ih.is_all_zeros() && port != 0) if (!ih.is_all_zeros() && port != 0)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("<== LSD: %s:%d ih: %s" debug_log("<== LSD: %s:%d ih: %s"
, print_address(from.address()).c_str() , print_address(from.address()).c_str()
, port, ih_str.c_str()); , port, ih_str.c_str());

View File

@ -209,7 +209,7 @@ namespace libtorrent { namespace
// invalid tex message // invalid tex message
if (added == 0) if (added == 0)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log(" <== LT_TEX [ NOT A DICTIONARY ]"); m_pc.peer_log(" <== LT_TEX [ NOT A DICTIONARY ]");
#endif #endif
return true; return true;
@ -217,14 +217,14 @@ namespace libtorrent { namespace
if (m_tp.num_tex_trackers() >= 50) if (m_tp.num_tex_trackers() >= 50)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log(" <== LT_TEX [ we already have %d trackers " m_pc.peer_log(" <== LT_TEX [ we already have %d trackers "
"from tex, don't add any more", m_tp.num_tex_trackers()); "from tex, don't add any more", m_tp.num_tex_trackers());
#endif #endif
return true; return true;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::stringstream log_line; std::stringstream log_line;
log_line << aux::time_now_string() << " <== LT_TEX [ " log_line << aux::time_now_string() << " <== LT_TEX [ "
"added: "; "added: ";
@ -259,7 +259,7 @@ namespace libtorrent { namespace
if (m_tp.num_tex_trackers() >= 50) if (m_tp.num_tex_trackers() >= 50)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_line << "**reached-limit** "; log_line << "**reached-limit** ";
#endif #endif
break; break;
@ -271,11 +271,11 @@ namespace libtorrent { namespace
if (m_torrent.add_tracker(e)) if (m_torrent.add_tracker(e))
m_tp.increment_tracker_counter(); m_tp.increment_tracker_counter();
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_line << e.url << " "; log_line << e.url << " ";
#endif #endif
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_line << "]\n"; log_line << "]\n";
m_pc.peer_log("%s", log_line.str().c_str()); m_pc.peer_log("%s", log_line.str().c_str());
#endif #endif
@ -329,7 +329,7 @@ namespace libtorrent { namespace
if (!m_torrent.valid_metadata() || m_torrent.torrent_file().priv()) if (!m_torrent.valid_metadata() || m_torrent.torrent_file().priv())
return false; return false;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::stringstream log_line; std::stringstream log_line;
log_line << aux::time_now_string() << " ==> LT_TEX [ " log_line << aux::time_now_string() << " ==> LT_TEX [ "
"added: "; "added: ";
@ -341,14 +341,14 @@ namespace libtorrent { namespace
{ {
if (!send_tracker(*i)) continue; if (!send_tracker(*i)) continue;
added.push_back(i->url); added.push_back(i->url);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_line << i->url << " "; log_line << i->url << " ";
#endif #endif
} }
std::vector<char> tex_msg; std::vector<char> tex_msg;
bencode(std::back_inserter(tex_msg), tex); bencode(std::back_inserter(tex_msg), tex);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_line << "]"; log_line << "]";
m_pc.peer_log("%s", log_line.str().c_str()); m_pc.peer_log("%s", log_line.str().c_str());
#endif #endif

View File

@ -304,7 +304,7 @@ namespace libtorrent { namespace
// abort if the peer doesn't support the metadata extension // abort if the peer doesn't support the metadata extension
if (m_message_index == 0) return; if (m_message_index == 0) return;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("==> METADATA_REQUEST [ start: %d | size: %d ]\n" m_pc.peer_log("==> METADATA_REQUEST [ start: %d | size: %d ]\n"
, start, size); , start, size);
#endif #endif
@ -342,7 +342,7 @@ namespace libtorrent { namespace
char msg[15]; char msg[15];
char* ptr = msg; char* ptr = msg;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("==> METADATA [ start: %d | total_size: %d | offset: %d | data_size: %d ]" m_pc.peer_log("==> METADATA [ start: %d | total_size: %d | offset: %d | data_size: %d ]"
, req.first, req.second, offset.first, offset.second); , req.first, req.second, offset.first, offset.second);
#endif #endif
@ -363,7 +363,7 @@ namespace libtorrent { namespace
} }
else else
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("==> DONT HAVE METADATA\n"); m_pc.peer_log("==> DONT HAVE METADATA\n");
#endif #endif
char msg[4+3]; char msg[4+3];
@ -404,7 +404,7 @@ namespace libtorrent { namespace
int start = detail::read_uint8(body.begin); int start = detail::read_uint8(body.begin);
int size = detail::read_uint8(body.begin) + 1; int size = detail::read_uint8(body.begin) + 1;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== METADATA_REQUEST [ start: %d | size: %d ]\n" m_pc.peer_log("<== METADATA_REQUEST [ start: %d | size: %d ]\n"
, start, size); , start, size);
#endif #endif
@ -427,7 +427,7 @@ namespace libtorrent { namespace
int offset = detail::read_int32(body.begin); int offset = detail::read_int32(body.begin);
int data_size = length - 9; int data_size = length - 9;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== METADATA [ total_size: %d | offset: %d | data_size: %d ]" m_pc.peer_log("<== METADATA [ total_size: %d | offset: %d | data_size: %d ]"
,total_size, offset, data_size); ,total_size, offset, data_size);
#endif #endif
@ -470,7 +470,7 @@ namespace libtorrent { namespace
if (m_waiting_metadata_request) if (m_waiting_metadata_request)
m_tp.cancel_metadata_request(m_last_metadata_request); m_tp.cancel_metadata_request(m_last_metadata_request);
m_waiting_metadata_request = false; m_waiting_metadata_request = false;
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== DONT HAVE METADATA\n"); m_pc.peer_log("<== DONT HAVE METADATA\n");
#endif #endif
break; break;

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_io.hpp" // for print_endpoint #include "libtorrent/socket_io.hpp" // for print_endpoint
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/socket_io.hpp" // for print_endpoint #include "libtorrent/socket_io.hpp" // for print_endpoint
#include "libtorrent/ip_voter.hpp" // for external_ip #include "libtorrent/ip_voter.hpp" // for external_ip
#endif #endif
@ -620,7 +620,7 @@ namespace libtorrent
TORRENT_ASSERT(i->connection != &c); TORRENT_ASSERT(i->connection != &c);
TORRENT_ASSERT(i->address() == c.remote().address()); TORRENT_ASSERT(i->address() == c.remote().address());
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
c.peer_log("*** DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]" c.peer_log("*** DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]"
, print_address(c.remote().address()).c_str() , print_address(c.remote().address()).c_str()
, print_address(i->address()).c_str()); , print_address(i->address()).c_str());
@ -678,7 +678,7 @@ namespace libtorrent
if (our_port < other_port) if (our_port < other_port)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port); c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port); i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
#endif #endif
@ -696,7 +696,7 @@ namespace libtorrent
} }
else else
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port); c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port); i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
#endif #endif

View File

@ -90,7 +90,7 @@ namespace libtorrent
- (int)c.download_queue().size() - (int)c.download_queue().size()
- (int)c.request_queue().size(); - (int)c.request_queue().size();
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
c.peer_log("*** PIECE_PICKER [ dlq: %d rqq: %d target: %d req: %d engame: %d ]" c.peer_log("*** PIECE_PICKER [ dlq: %d rqq: %d target: %d req: %d engame: %d ]"
, int(c.download_queue().size()), int(c.request_queue().size()) , int(c.download_queue().size()), int(c.request_queue().size())
, c.desired_queue_size(), num_requests, c.endgame()); , c.desired_queue_size(), num_requests, c.endgame());
@ -162,7 +162,7 @@ namespace libtorrent
, c.picker_options(), suggested, t.num_peers() , c.picker_options(), suggested, t.num_peers()
, ses.stats_counters()); , ses.stats_counters());
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
c.peer_log("*** PIECE_PICKER [ prefer_contiguous: %d picked: %d ]" c.peer_log("*** PIECE_PICKER [ prefer_contiguous: %d picked: %d ]"
, prefer_contiguous_blocks, int(interesting_pieces.size())); , prefer_contiguous_blocks, int(interesting_pieces.size()));
#endif #endif
@ -227,7 +227,7 @@ namespace libtorrent
= std::find_if(dq.begin(), dq.end(), has_block(*i)); = std::find_if(dq.begin(), dq.end(), has_block(*i));
if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted); if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted);
#endif #endif
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
c.peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in queue ]" c.peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in queue ]"
, i->piece_index, i->block_index); , i->piece_index, i->block_index);
#endif #endif

View File

@ -99,7 +99,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/socket_io.hpp" #include "libtorrent/socket_io.hpp"
@ -118,7 +118,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/http_tracker_connection.hpp" #include "libtorrent/http_tracker_connection.hpp"
#include "libtorrent/udp_tracker_connection.hpp" #include "libtorrent/udp_tracker_connection.hpp"
#endif // TORRENT_LOGGING #endif // TORRENT_DISABLE_LOGGING
#ifdef TORRENT_USE_GCRYPT #ifdef TORRENT_USE_GCRYPT
@ -361,7 +361,7 @@ namespace aux {
#endif #endif
, m_tracker_manager(m_udp_socket, m_stats_counters, m_host_resolver , m_tracker_manager(m_udp_socket, m_stats_counters, m_host_resolver
, m_ip_filter, m_settings , m_ip_filter, m_settings
#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, *this , *this
#endif #endif
) )
@ -461,7 +461,7 @@ namespace aux {
{ {
m_alerts.set_alert_mask(pack.get_int(settings_pack::alert_mask)); m_alerts.set_alert_mask(pack.get_int(settings_pack::alert_mask));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("start session"); session_log("start session");
#endif #endif
@ -518,7 +518,7 @@ namespace aux {
// TODO: there's no rule here to make uTP connections not have the global or // TODO: there's no rule here to make uTP connections not have the global or
// local rate limits apply to it. This used to be the default. // local rate limits apply to it. This used to be the default.
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("config: %s\n" session_log("config: %s\n"
"version: %s\n" "version: %s\n"
@ -527,7 +527,7 @@ namespace aux {
, LIBTORRENT_VERSION , LIBTORRENT_VERSION
, LIBTORRENT_REVISION); , LIBTORRENT_REVISION);
#endif // TORRENT_LOGGING #endif // TORRENT_DISABLE_LOGGING
#if TORRENT_USE_RLIMIT #if TORRENT_USE_RLIMIT
// ---- auto-cap max connections ---- // ---- auto-cap max connections ----
@ -535,7 +535,7 @@ namespace aux {
struct rlimit rl; struct rlimit rl;
if (getrlimit(RLIMIT_NOFILE, &rl) == 0) if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" max number of open files: %d", rl.rlim_cur); session_log(" max number of open files: %d", rl.rlim_cur);
#endif #endif
// deduct some margin for epoll/kqueue, log files, // deduct some margin for epoll/kqueue, log files,
@ -547,7 +547,7 @@ namespace aux {
m_settings.get_int(settings_pack::connections_limit) m_settings.get_int(settings_pack::connections_limit)
, int(rl.rlim_cur * 8 / 10))); , int(rl.rlim_cur * 8 / 10)));
// 20% goes towards regular files (see disk_io_thread) // 20% goes towards regular files (see disk_io_thread)
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" max connections: %d", m_settings.get_int(settings_pack::connections_limit)); session_log(" max connections: %d", m_settings.get_int(settings_pack::connections_limit));
session_log(" max files: %d", int(rl.rlim_cur * 2 / 10)); session_log(" max files: %d", int(rl.rlim_cur * 2 / 10));
#endif #endif
@ -555,7 +555,7 @@ namespace aux {
#endif // TORRENT_USE_RLIMIT #endif // TORRENT_USE_RLIMIT
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" generated peer ID: %s", m_peer_id.to_string().c_str()); session_log(" generated peer ID: %s", m_peer_id.to_string().c_str());
#endif #endif
@ -564,7 +564,7 @@ namespace aux {
// call update_* after settings set initialized // call update_* after settings set initialized
m_io_service.post(boost::bind(&session_impl::init_settings, this)); m_io_service.post(boost::bind(&session_impl::init_settings, this));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" spawning network thread"); session_log(" spawning network thread");
#endif #endif
m_thread.reset(new thread(boost::bind(&session_impl::main_thread, this))); m_thread.reset(new thread(boost::bind(&session_impl::main_thread, this)));
@ -655,7 +655,7 @@ namespace aux {
void session_impl::init() void session_impl::init()
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" *** session thread init"); session_log(" *** session thread init");
#endif #endif
@ -684,7 +684,7 @@ namespace aux {
update_dht_announce_interval(); update_dht_announce_interval();
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" done starting session"); session_log(" done starting session");
#endif #endif
} }
@ -950,7 +950,7 @@ namespace aux {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (m_paused) return; if (m_paused) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" *** session paused ***"); session_log(" *** session paused ***");
#endif #endif
m_paused = true; m_paused = true;
@ -982,7 +982,7 @@ namespace aux {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (m_abort) return; if (m_abort) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" *** ABORT CALLED ***"); session_log(" *** ABORT CALLED ***");
#endif #endif
@ -1038,7 +1038,7 @@ namespace aux {
m_i2p_listen_socket.reset(); m_i2p_listen_socket.reset();
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" aborting all torrents (%d)", m_torrents.size()); session_log(" aborting all torrents (%d)", m_torrents.size());
#endif #endif
// abort all torrents // abort all torrents
@ -1049,12 +1049,12 @@ namespace aux {
} }
m_torrents.clear(); m_torrents.clear();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" aborting all tracker requests"); session_log(" aborting all tracker requests");
#endif #endif
m_tracker_manager.abort_all_requests(); m_tracker_manager.abort_all_requests();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" aborting all connections (%d)", m_connections.size()); session_log(" aborting all connections (%d)", m_connections.size());
#endif #endif
// abort all connections // abort all connections
@ -1580,7 +1580,7 @@ namespace aux {
if (m_alerts.should_post<listen_failed_alert>()) if (m_alerts.should_post<listen_failed_alert>())
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type); m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("failed to open socket: %s: %s" session_log("failed to open socket: %s: %s"
, device.c_str(), ec.message().c_str()); , device.c_str(), ec.message().c_str());
#endif #endif
@ -1622,7 +1622,7 @@ namespace aux {
while (ec && retries > 0) while (ec && retries > 0)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("failed to bind to interface [%s] \"%s\": %s" session_log("failed to bind to interface [%s] \"%s\": %s"
, device.c_str(), bind_ip.to_string(ec).c_str() , device.c_str(), bind_ip.to_string(ec).c_str()
, ec.message().c_str()); , ec.message().c_str());
@ -1650,7 +1650,7 @@ namespace aux {
// not even that worked, give up // not even that worked, give up
if (m_alerts.should_post<listen_failed_alert>()) if (m_alerts.should_post<listen_failed_alert>())
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type); m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("cannot bind to interface \"%s\": %s" session_log("cannot bind to interface \"%s\": %s"
, device.c_str(), ec.message().c_str()); , device.c_str(), ec.message().c_str());
#endif #endif
@ -1668,7 +1668,7 @@ namespace aux {
{ {
if (m_alerts.should_post<listen_failed_alert>()) if (m_alerts.should_post<listen_failed_alert>())
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type); m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("cannot listen on interface \"%s\": %s" session_log("cannot listen on interface \"%s\": %s"
, device.c_str(), ec.message().c_str()); , device.c_str(), ec.message().c_str());
#endif #endif
@ -1685,7 +1685,7 @@ namespace aux {
{ {
if (m_alerts.should_post<listen_failed_alert>()) if (m_alerts.should_post<listen_failed_alert>())
m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type); m_alerts.emplace_alert<listen_failed_alert>(device, last_op, ec, sock_type);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("failed to get peer name \"%s\": %s" session_log("failed to get peer name \"%s\": %s"
, device.c_str(), ec.message().c_str()); , device.c_str(), ec.message().c_str());
#endif #endif
@ -1698,7 +1698,7 @@ namespace aux {
, (flags & open_ssl_socket) ? listen_succeeded_alert::tcp_ssl , (flags & open_ssl_socket) ? listen_succeeded_alert::tcp_ssl
: listen_succeeded_alert::tcp); : listen_succeeded_alert::tcp);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" listening on: %s external port: %d" session_log(" listening on: %s external port: %d"
, print_endpoint(tcp::endpoint(bind_ip, port)).c_str(), ret.external_port); , print_endpoint(tcp::endpoint(bind_ip, port)).c_str(), ret.external_port);
#endif #endif
@ -1707,7 +1707,7 @@ namespace aux {
void session_impl::open_listen_port() void session_impl::open_listen_port()
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("open listen port"); session_log("open listen port");
#endif #endif
@ -1900,7 +1900,7 @@ retry:
if (m_listen_sockets.empty() && ec) if (m_listen_sockets.empty() && ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("cannot bind TCP listen socket to interface \"%s\": %s" session_log("cannot bind TCP listen socket to interface \"%s\": %s"
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); , print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
#endif #endif
@ -1928,7 +1928,7 @@ retry:
m_ssl_udp_socket.bind(ssl_bind_if, ec); m_ssl_udp_socket.bind(ssl_bind_if, ec);
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("SSL: cannot bind to UDP interface \"%s\": %s" session_log("SSL: cannot bind to UDP interface \"%s\": %s"
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); , print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
#endif #endif
@ -1954,7 +1954,7 @@ retry:
m_udp_socket.bind(udp::endpoint(m_listen_interface.address(), m_listen_interface.port()), ec); m_udp_socket.bind(udp::endpoint(m_listen_interface.address(), m_listen_interface.port()), ec);
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("cannot bind to UDP interface \"%s\": %s" session_log("cannot bind to UDP interface \"%s\": %s"
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); , print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
#endif #endif
@ -2101,7 +2101,7 @@ retry:
if (m_alerts.should_post<i2p_alert>()) if (m_alerts.should_post<i2p_alert>())
m_alerts.emplace_alert<i2p_alert>(ec); m_alerts.emplace_alert<i2p_alert>(ec);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("i2p open failed (%d) %s", ec.value(), ec.message().c_str()); session_log("i2p open failed (%d) %s", ec.value(), ec.message().c_str());
#endif #endif
} }
@ -2146,7 +2146,7 @@ retry:
if (m_alerts.should_post<listen_failed_alert>()) if (m_alerts.should_post<listen_failed_alert>())
m_alerts.emplace_alert<listen_failed_alert>("i2p", listen_failed_alert::accept m_alerts.emplace_alert<listen_failed_alert>("i2p", listen_failed_alert::accept
, e, listen_failed_alert::i2p); , e, listen_failed_alert::i2p);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("cannot bind to port %d: %s" session_log("cannot bind to port %d: %s"
, m_listen_interface.port(), e.message().c_str()); , m_listen_interface.port(), e.message().c_str());
#endif #endif
@ -2169,7 +2169,7 @@ retry:
&& m_alerts.should_post<udp_error_alert>()) && m_alerts.should_post<udp_error_alert>())
m_alerts.emplace_alert<udp_error_alert>(ep, ec); m_alerts.emplace_alert<udp_error_alert>(ep, ec);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("UDP socket error: (%d) %s", ec.value(), ec.message().c_str()); session_log("UDP socket error: (%d) %s", ec.value(), ec.message().c_str());
#endif #endif
} }
@ -2231,7 +2231,7 @@ retry:
if (e) if (e)
{ {
tcp::endpoint ep = listener->local_endpoint(ec); tcp::endpoint ep = listener->local_endpoint(ec);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("error accepting connection on '%s': %s" session_log("error accepting connection on '%s': %s"
, print_endpoint(ep).c_str(), e.message().c_str()); , print_endpoint(ep).c_str(), e.message().c_str());
#endif #endif
@ -2346,7 +2346,7 @@ retry:
tcp::endpoint endp = s->remote_endpoint(e); tcp::endpoint endp = s->remote_endpoint(e);
if (e) return; if (e) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" *** peer SSL handshake done [ ip: %s ec: %s socket: %s ]" session_log(" *** peer SSL handshake done [ ip: %s ec: %s socket: %s ]"
, print_endpoint(endp).c_str(), ec.message().c_str(), s->type_name()); , print_endpoint(endp).c_str(), ec.message().c_str(), s->type_name());
#endif #endif
@ -2379,7 +2379,7 @@ retry:
if (m_paused) if (m_paused)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" <== INCOMING CONNECTION [ ignored, paused ]"); session_log(" <== INCOMING CONNECTION [ ignored, paused ]");
#endif #endif
return; return;
@ -2391,7 +2391,7 @@ retry:
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("%s <== INCOMING CONNECTION FAILED, could " session_log("%s <== INCOMING CONNECTION FAILED, could "
"not retrieve remote endpoint " "not retrieve remote endpoint "
, print_endpoint(endp).c_str(), ec.message().c_str()); , print_endpoint(endp).c_str(), ec.message().c_str());
@ -2399,7 +2399,7 @@ retry:
return; return;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" <== INCOMING CONNECTION %s type: %s" session_log(" <== INCOMING CONNECTION %s type: %s"
, print_endpoint(endp).c_str(), s->type_name()); , print_endpoint(endp).c_str(), s->type_name());
#endif #endif
@ -2407,7 +2407,7 @@ retry:
if (!m_settings.get_bool(settings_pack::enable_incoming_utp) if (!m_settings.get_bool(settings_pack::enable_incoming_utp)
&& is_utp(*s)) && is_utp(*s))
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" rejected uTP connection"); session_log(" rejected uTP connection");
#endif #endif
if (m_alerts.should_post<peer_blocked_alert>()) if (m_alerts.should_post<peer_blocked_alert>())
@ -2419,7 +2419,7 @@ retry:
if (!m_settings.get_bool(settings_pack::enable_incoming_tcp) if (!m_settings.get_bool(settings_pack::enable_incoming_tcp)
&& s->get<stream_socket>()) && s->get<stream_socket>())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" rejected TCP connection"); session_log(" rejected TCP connection");
#endif #endif
if (m_alerts.should_post<peer_blocked_alert>()) if (m_alerts.should_post<peer_blocked_alert>())
@ -2436,7 +2436,7 @@ retry:
tcp::endpoint local = s->local_endpoint(ec); tcp::endpoint local = s->local_endpoint(ec);
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" rejected connection: (%d) %s", ec.value() session_log(" rejected connection: (%d) %s", ec.value()
, ec.message().c_str()); , ec.message().c_str());
#endif #endif
@ -2447,14 +2447,14 @@ retry:
{ {
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" rejected connection, not allowed local interface: (%d) %s" session_log(" rejected connection, not allowed local interface: (%d) %s"
, ec.value(), ec.message().c_str()); , ec.value(), ec.message().c_str());
#endif #endif
return; return;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" rejected connection, not allowed local interface: %s" session_log(" rejected connection, not allowed local interface: %s"
, local.address().to_string(ec).c_str()); , local.address().to_string(ec).c_str());
#endif #endif
@ -2478,7 +2478,7 @@ retry:
if (m_stats_counters[counters::non_filter_torrents] == 0 if (m_stats_counters[counters::non_filter_torrents] == 0
&& (m_ip_filter.access(endp.address()) & ip_filter::blocked)) && (m_ip_filter.access(endp.address()) & ip_filter::blocked))
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("filtered blocked ip"); session_log("filtered blocked ip");
#endif #endif
if (m_alerts.should_post<peer_blocked_alert>()) if (m_alerts.should_post<peer_blocked_alert>())
@ -2491,7 +2491,7 @@ retry:
// if we don't reject the connection // if we don't reject the connection
if (m_torrents.empty()) if (m_torrents.empty())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" There are no torrents, disconnect"); session_log(" There are no torrents, disconnect");
#endif #endif
return; return;
@ -2527,7 +2527,7 @@ retry:
, error_code(errors::too_many_connections, get_libtorrent_category()) , error_code(errors::too_many_connections, get_libtorrent_category())
, close_no_reason); , close_no_reason);
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("number of connections limit exceeded (conns: %d, limit: %d, slack: %d), connection rejected" session_log("number of connections limit exceeded (conns: %d, limit: %d, slack: %d), connection rejected"
, num_connections(), m_settings.get_int(settings_pack::connections_limit) , num_connections(), m_settings.get_int(settings_pack::connections_limit)
, m_settings.get_int(settings_pack::connections_slack)); , m_settings.get_int(settings_pack::connections_slack));
@ -2554,7 +2554,7 @@ retry:
} }
if (!has_active_torrent) if (!has_active_torrent)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" There are no _active_ torrents, disconnect"); session_log(" There are no _active_ torrents, disconnect");
#endif #endif
return; return;
@ -2651,7 +2651,7 @@ retry:
// TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p)); // TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p));
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" CLOSING CONNECTION %s : %s" session_log(" CLOSING CONNECTION %s : %s"
, print_endpoint(p->remote()).c_str(), ec.message().c_str()); , print_endpoint(p->remote()).c_str(), ec.message().c_str());
#endif #endif
@ -2686,7 +2686,7 @@ retry:
int port = m_next_port; int port = m_next_port;
++m_next_port; ++m_next_port;
if (m_next_port > out_ports.second) m_next_port = out_ports.first; if (m_next_port > out_ports.second) m_next_port = out_ports.first;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" *** BINDING OUTGOING CONNECTION [ port: %d ]", port); session_log(" *** BINDING OUTGOING CONNECTION [ port: %d ]", port);
#endif #endif
return port; return port;
@ -2833,7 +2833,7 @@ retry:
if (e) if (e)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("*** TICK TIMER FAILED %s", e.message().c_str()); session_log("*** TICK TIMER FAILED %s", e.message().c_str());
#endif #endif
::abort(); ::abort();
@ -3301,7 +3301,7 @@ retry:
TORRENT_ASSERT(m_dht); TORRENT_ASSERT(m_dht);
m_dht_torrents.push_back(t); m_dht_torrents.push_back(t);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<torrent> tor = t.lock(); boost::shared_ptr<torrent> tor = t.lock();
if (tor) if (tor)
session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str()); session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str());
@ -3330,7 +3330,7 @@ retry:
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (e) if (e)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("aborting DHT announce timer (%d): %s" session_log("aborting DHT announce timer (%d): %s"
, e.value(), e.message().c_str()); , e.value(), e.message().c_str());
#endif #endif
@ -3339,7 +3339,7 @@ retry:
if (m_abort) if (m_abort)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("aborting DHT announce timer: m_abort set"); session_log("aborting DHT announce timer: m_abort set");
#endif #endif
return; return;
@ -3473,7 +3473,7 @@ retry:
{ {
--hard_limit; --hard_limit;
--type_limit; --type_limit;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (!t->allows_peers()) if (!t->allows_peers())
t->log_to_all_peers("AUTO MANAGER STARTING TORRENT"); t->log_to_all_peers("AUTO MANAGER STARTING TORRENT");
#endif #endif
@ -3481,7 +3481,7 @@ retry:
} }
else else
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (t->allows_peers()) if (t->allows_peers())
t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT"); t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT");
#endif #endif
@ -4040,7 +4040,7 @@ retry:
stop_loop = m_abort; stop_loop = m_abort;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" locking mutex"); session_log(" locking mutex");
#endif #endif
@ -4053,7 +4053,7 @@ retry:
} }
#endif #endif
*/ */
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" cleaning up torrents"); session_log(" cleaning up torrents");
#endif #endif
@ -4276,7 +4276,7 @@ retry:
return i->second; return i->second;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
void session_impl::session_log(char const* fmt, ...) const void session_impl::session_log(char const* fmt, ...) const
{ {
if (!m_alerts.should_post<log_alert>()) return; if (!m_alerts.should_post<log_alert>()) return;
@ -4555,7 +4555,7 @@ retry:
error_code ec; error_code ec;
bdecode_node tmp; bdecode_node tmp;
bdecode_node info; bdecode_node info;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("adding magnet link with resume data"); session_log("adding magnet link with resume data");
#endif #endif
if (bdecode(&params.resume_data[0], &params.resume_data[0] if (bdecode(&params.resume_data[0], &params.resume_data[0]
@ -4563,7 +4563,7 @@ retry:
&& tmp.type() == bdecode_node::dict_t && tmp.type() == bdecode_node::dict_t
&& (info = tmp.dict_find_dict("info"))) && (info = tmp.dict_find_dict("info")))
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("found metadata in resume data"); session_log("found metadata in resume data");
#endif #endif
// verify the info-hash of the metadata stored in the resume file matches // verify the info-hash of the metadata stored in the resume file matches
@ -4579,14 +4579,14 @@ retry:
|| !params.url.empty() || !params.url.empty()
|| params.info_hash.is_all_zeros()) || params.info_hash.is_all_zeros())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("info-hash matched"); session_log("info-hash matched");
#endif #endif
params.ti = boost::make_shared<torrent_info>(resume_ih); params.ti = boost::make_shared<torrent_info>(resume_ih);
if (params.ti->parse_info_section(info, ec, 0)) if (params.ti->parse_info_section(info, ec, 0))
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("successfully loaded metadata from resume file"); session_log("successfully loaded metadata from resume file");
#endif #endif
// make the info-hash be the one in the resume file // make the info-hash be the one in the resume file
@ -4595,20 +4595,20 @@ retry:
} }
else else
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("failed to load metadata from resume file: %s" session_log("failed to load metadata from resume file: %s"
, ec.message().c_str()); , ec.message().c_str());
#endif #endif
} }
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
else else
{ {
session_log("metadata info-hash failed"); session_log("metadata info-hash failed");
} }
#endif #endif
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
else else
{ {
session_log("no metadata found"); session_log("no metadata found");
@ -4936,7 +4936,7 @@ retry:
// declared in string_util.hpp // declared in string_util.hpp
parse_comma_separated_string_port(net_interfaces, new_listen_interfaces); parse_comma_separated_string_port(net_interfaces, new_listen_interfaces);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("update listen interfaces: %s", net_interfaces.c_str()); session_log("update listen interfaces: %s", net_interfaces.c_str());
#endif #endif
@ -4964,14 +4964,14 @@ retry:
device_name[0] == '[' ? device_name + 1 : device_name, ec)); device_name[0] == '[' ? device_name + 1 : device_name, ec));
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("failed to treat %s as an IP address [ %s ]" session_log("failed to treat %s as an IP address [ %s ]"
, device_name, ec.message().c_str()); , device_name, ec.message().c_str());
#endif #endif
// it may have been a device name. // it may have been a device name.
std::vector<ip_interface> ifs = enum_net_interfaces(m_io_service, ec); std::vector<ip_interface> ifs = enum_net_interfaces(m_io_service, ec);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (ec) if (ec)
session_log("failed to enumerate interfaces [ %s ]" session_log("failed to enumerate interfaces [ %s ]"
, ec.message().c_str()); , ec.message().c_str());
@ -4985,7 +4985,7 @@ retry:
// connecting to) // connecting to)
if (strcmp(ifs[i].name, device_name) != 0) continue; if (strcmp(ifs[i].name, device_name) != 0) continue;
m_listen_interface.address(ifs[i].interface_address); m_listen_interface.address(ifs[i].interface_address);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("binding to %s" session_log("binding to %s"
, m_listen_interface.address().to_string(ec).c_str()); , m_listen_interface.address().to_string(ec).c_str());
#endif #endif
@ -4995,7 +4995,7 @@ retry:
if (!found) if (!found)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("failed to find device %s", device_name); session_log("failed to find device %s", device_name);
#endif #endif
// effectively disable whatever socket decides to bind to this // effectively disable whatever socket decides to bind to this
@ -5180,7 +5180,7 @@ retry:
if (t->torrent_file().priv() || (t->torrent_file().is_i2p() if (t->torrent_file().priv() || (t->torrent_file().is_i2p()
&& !m_settings.get_bool(settings_pack::allow_i2p_mixed))) return; && !m_settings.get_bool(settings_pack::allow_i2p_mixed))) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("added peer from local discovery: %s", print_endpoint(peer).c_str()); session_log("added peer from local discovery: %s", print_endpoint(peer).c_str());
#endif #endif
t->add_peer(peer, peer_info::lsd); t->add_peer(peer, peer_info::lsd);
@ -5757,7 +5757,7 @@ retry:
m_ssl_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec); m_ssl_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec);
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(">>> SET_TOS [ udp_socket tos: %x e: %s ]" session_log(">>> SET_TOS [ udp_socket tos: %x e: %s ]"
, m_settings.get_int(settings_pack::peer_tos) , m_settings.get_int(settings_pack::peer_tos)
, ec.message().c_str()); , ec.message().c_str());
@ -5967,7 +5967,7 @@ retry:
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
if (!m_dht) if (!m_dht)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("not starting DHT announce timer: m_dht == NULL"); session_log("not starting DHT announce timer: m_dht == NULL");
#endif #endif
return; return;
@ -5978,7 +5978,7 @@ retry:
// if we haven't started yet, don't actually trigger this // if we haven't started yet, don't actually trigger this
if (!m_thread) if (!m_thread)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("not starting DHT announce timer: thread not running yet"); session_log("not starting DHT announce timer: thread not running yet");
#endif #endif
return; return;
@ -5986,7 +5986,7 @@ retry:
if (m_abort) if (m_abort)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log("not starting DHT announce timer: m_abort set"); session_log("not starting DHT announce timer: m_abort set");
#endif #endif
return; return;
@ -6276,7 +6276,7 @@ retry:
m_lsd = boost::make_shared<lsd>(boost::ref(m_io_service) m_lsd = boost::make_shared<lsd>(boost::ref(m_io_service)
, boost::bind(&session_impl::on_lsd_peer, this, _1, _2) , boost::bind(&session_impl::on_lsd_peer, this, _1, _2)
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
, boost::bind(&session_impl::on_lsd_log, this, _1) , boost::bind(&session_impl::on_lsd_log, this, _1)
#endif #endif
); );
@ -6286,7 +6286,7 @@ retry:
m_alerts.emplace_alert<lsd_error_alert>(ec); m_alerts.emplace_alert<lsd_error_alert>(ec);
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
void session_impl::on_lsd_log(char const* log) void session_impl::on_lsd_log(char const* log)
{ {
if (!m_alerts.should_post<log_alert>()) return; if (!m_alerts.should_post<log_alert>()) return;
@ -6456,14 +6456,14 @@ retry:
void session_impl::set_external_address(address const& ip void session_impl::set_external_address(address const& ip
, int source_type, address const& source) , int source_type, address const& source)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(": set_external_address(%s, %d, %s)", print_address(ip).c_str() session_log(": set_external_address(%s, %d, %s)", print_address(ip).c_str()
, source_type, print_address(source).c_str()); , source_type, print_address(source).c_str());
#endif #endif
if (!m_external_ip.cast_vote(ip, source_type, source)) return; if (!m_external_ip.cast_vote(ip, source_type, source)) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
session_log(" external IP updated"); session_log(" external IP updated");
#endif #endif
@ -6734,7 +6734,7 @@ retry:
} }
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
tracker_logger::tracker_logger(session_interface& ses): m_ses(ses) {} tracker_logger::tracker_logger(session_interface& ses): m_ses(ses) {}
void tracker_logger::tracker_warning(tracker_request const& req void tracker_logger::tracker_warning(tracker_request const& req
, std::string const& str) , std::string const& str)
@ -6747,7 +6747,7 @@ retry:
, std::list<address> const& ip_list , std::list<address> const& ip_list
, struct tracker_response const& resp) , struct tracker_response const& resp)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("TRACKER RESPONSE\n" debug_log("TRACKER RESPONSE\n"
"interval: %d\n" "interval: %d\n"
"external ip: %s\n" "external ip: %s\n"

View File

@ -62,7 +62,7 @@ POSSIBILITY OF SUCH DAMAGE.
//#define TORRENT_LOG_HASH_FAILURES //#define TORRENT_LOG_HASH_FAILURES
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/socket_io.hpp" #include "libtorrent/socket_io.hpp"
#endif #endif
@ -139,7 +139,7 @@ namespace
void on_piece_pass(int p) void on_piece_pass(int p)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_torrent.debug_log(" PIECE PASS [ p: %d | block_hash_size: %d ]" m_torrent.debug_log(" PIECE PASS [ p: %d | block_hash_size: %d ]"
, p, int(m_block_hashes.size())); , p, int(m_block_hashes.size()));
#endif #endif
@ -275,7 +275,7 @@ namespace
// this time the digest of the block is different // this time the digest of the block is different
// from the first time it sent it // from the first time it sent it
// at least one of them must be bad // at least one of them must be bad
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char const* client = "-"; char const* client = "-";
peer_info info; peer_info info;
if (p->connection) if (p->connection)
@ -301,7 +301,7 @@ namespace
m_block_hashes.insert(i, std::pair<const piece_block, block_entry>(b, e)); m_block_hashes.insert(i, std::pair<const piece_block, block_entry>(b, e));
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char const* client = "-"; char const* client = "-";
peer_info info; peer_info info;
if (p->connection) if (p->connection)
@ -350,7 +350,7 @@ namespace
} }
if (p == NULL) return; if (p == NULL) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char const* client = "-"; char const* client = "-";
peer_info info; peer_info info;
if (p->connection) if (p->connection)

View File

@ -97,7 +97,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif // BOOST_VERSION #endif // BOOST_VERSION
#endif // TORRENT_USE_OPENSSL #endif // TORRENT_USE_OPENSSL
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/aux_/session_impl.hpp" // for tracker_logger #include "libtorrent/aux_/session_impl.hpp" // for tracker_logger
#endif #endif
@ -719,12 +719,12 @@ namespace libtorrent
// TODO: 2 post alert // TODO: 2 post alert
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** FAILED SEED MODE, rechecking"); debug_log("*** FAILED SEED MODE, rechecking");
#endif #endif
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** LEAVING SEED MODE (%s)", seed ? "as seed" : "as non-seed"); debug_log("*** LEAVING SEED MODE (%s)", seed ? "as seed" : "as non-seed");
#endif #endif
m_seed_mode = false; m_seed_mode = false;
@ -755,7 +755,7 @@ namespace libtorrent
void torrent::start() void torrent::start()
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("starting torrent"); debug_log("starting torrent");
#endif #endif
std::vector<boost::uint64_t>().swap(m_file_progress); std::vector<boost::uint64_t>().swap(m_file_progress);
@ -768,7 +768,7 @@ namespace libtorrent
+ m_resume_data->buf.size(), m_resume_data->node, ec, &pos) != 0) + m_resume_data->buf.size(), m_resume_data->node, ec, &pos) != 0)
{ {
m_resume_data.reset(); m_resume_data.reset();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("resume data rejected: %s pos: %d", ec.message().c_str(), pos); debug_log("resume data rejected: %s pos: %d", ec.message().c_str(), pos);
#endif #endif
if (m_ses.alerts().should_post<fastresume_rejected_alert>()) if (m_ses.alerts().should_post<fastresume_rejected_alert>())
@ -1071,7 +1071,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (!j->error) return; if (!j->error) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("disk error: (%d) %s in file: %s", j->error.ec.value(), j->error.ec.message().c_str() debug_log("disk error: (%d) %s in file: %s", j->error.ec.value(), j->error.ec.message().c_str()
, resolve_filename(j->error.file).c_str()); , resolve_filename(j->error.file).c_str());
#endif #endif
@ -1474,7 +1474,7 @@ namespace libtorrent
GENERAL_NAMES* gens = static_cast<GENERAL_NAMES*>( GENERAL_NAMES* gens = static_cast<GENERAL_NAMES*>(
X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0)); X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::string names; std::string names;
bool match = false; bool match = false;
#endif #endif
@ -1487,14 +1487,14 @@ namespace libtorrent
const char* torrent_name = reinterpret_cast<const char*>(domain->data); const char* torrent_name = reinterpret_cast<const char*>(domain->data);
std::size_t name_length = domain->length; std::size_t name_length = domain->length;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (i > 1) names += " | n: "; if (i > 1) names += " | n: ";
names.append(torrent_name, name_length); names.append(torrent_name, name_length);
#endif #endif
if (strncmp(torrent_name, "*", name_length) == 0 if (strncmp(torrent_name, "*", name_length) == 0
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0) || strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
match = true; match = true;
// if we're logging, keep looping over all names, // if we're logging, keep looping over all names,
// for completeness of the log // for completeness of the log
@ -1519,7 +1519,7 @@ namespace libtorrent
const char* torrent_name = reinterpret_cast<const char*>(common_name->data); const char* torrent_name = reinterpret_cast<const char*>(common_name->data);
std::size_t name_length = common_name->length; std::size_t name_length = common_name->length;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (!names.empty()) names += " | n: "; if (!names.empty()) names += " | n: ";
names.append(torrent_name, name_length); names.append(torrent_name, name_length);
#endif #endif
@ -1527,7 +1527,7 @@ namespace libtorrent
if (strncmp(torrent_name, "*", name_length) == 0 if (strncmp(torrent_name, "*", name_length) == 0
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0) || strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
{ {
#if !defined TORRENT_LOGGING #ifdef TORRENT_DISABLE_LOGGING
return true; return true;
#else #else
match = true; match = true;
@ -1535,7 +1535,7 @@ namespace libtorrent
} }
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("<== incoming SSL CONNECTION [ n: %s | match: %s ]" debug_log("<== incoming SSL CONNECTION [ n: %s | match: %s ]"
, names.c_str(), match?"yes":"no"); , names.c_str(), match?"yes":"no");
return match; return match;
@ -1709,7 +1709,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("init torrent: %s", torrent_file().name().c_str()); debug_log("init torrent: %s", torrent_file().name().c_str());
#endif #endif
@ -1770,7 +1770,7 @@ namespace libtorrent
if (ev) if (ev)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("fastresume data rejected: %s" debug_log("fastresume data rejected: %s"
, error_code(ev, get_libtorrent_category()).message().c_str()); , error_code(ev, get_libtorrent_category()).message().c_str());
#endif #endif
@ -1989,7 +1989,7 @@ namespace libtorrent
m_storage.get(), m_resume_data ? &m_resume_data->node : NULL m_storage.get(), m_resume_data ? &m_resume_data->node : NULL
, links, boost::bind(&torrent::on_resume_data_checked , links, boost::bind(&torrent::on_resume_data_checked
, shared_from_this(), _1)); , shared_from_this(), _1));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("init, async_check_fastresume"); debug_log("init, async_check_fastresume");
#endif #endif
@ -2305,7 +2305,7 @@ namespace libtorrent
} }
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (m_peer_list && m_peer_list->num_peers() > 0) if (m_peer_list && m_peer_list->num_peers() > 0)
debug_log("resume added peers (%d)", m_peer_list->num_peers()); debug_log("resume added peers (%d)", m_peer_list->num_peers());
#endif #endif
@ -2318,13 +2318,13 @@ namespace libtorrent
, resolve_filename(j->error.file), j->error.operation_str()); , resolve_filename(j->error.file), j->error.operation_str());
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (j->ret != 0) if (j->ret != 0)
{ {
debug_log("fastresume data rejected: ret: %d (%d) %s" debug_log("fastresume data rejected: ret: %d (%d) %s"
, j->ret, j->error.ec.value(), j->error.ec.message().c_str()); , j->ret, j->error.ec.value(), j->error.ec.message().c_str());
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
else else
debug_log("fastresume data accepted"); debug_log("fastresume data accepted");
#endif #endif
@ -2548,7 +2548,7 @@ namespace libtorrent
// resumed quickly, before the outstanding jobs completed // resumed quickly, before the outstanding jobs completed
if (m_checking_piece >= m_torrent_file->num_pieces()) if (m_checking_piece >= m_torrent_file->num_pieces())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("start_checking, checking_piece >= num_pieces. %d >= %d" debug_log("start_checking, checking_piece >= num_pieces. %d >= %d"
, m_checking_piece, m_torrent_file->num_pieces()); , m_checking_piece, m_torrent_file->num_pieces());
#endif #endif
@ -2561,7 +2561,7 @@ namespace libtorrent
if (!need_loaded()) if (!need_loaded())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("start_checking, need_loaded() failed"); debug_log("start_checking, need_loaded() failed");
#endif #endif
return; return;
@ -2576,7 +2576,7 @@ namespace libtorrent
, shared_from_this(), _1), (void*)1); , shared_from_this(), _1), (void*)1);
if (m_checking_piece >= m_torrent_file->num_pieces()) break; if (m_checking_piece >= m_torrent_file->num_pieces()) break;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("start_checking, m_checking_piece: %d", m_checking_piece); debug_log("start_checking, m_checking_piece: %d", m_checking_piece);
#endif #endif
} }
@ -2599,7 +2599,7 @@ namespace libtorrent
{ {
m_checking_piece = 0; m_checking_piece = 0;
m_num_checked_pieces = 0; m_num_checked_pieces = 0;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("on_piece_hashed, disk_check_aborted"); debug_log("on_piece_hashed, disk_check_aborted");
#endif #endif
pause(); pause();
@ -2640,7 +2640,7 @@ namespace libtorrent
m_ses.alerts().emplace_alert<file_error_alert>(j->error.ec, m_ses.alerts().emplace_alert<file_error_alert>(j->error.ec,
resolve_filename(j->error.file), j->error.operation_str(), get_handle()); resolve_filename(j->error.file), j->error.operation_str(), get_handle());
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("on_piece_hashed, fatal disk error: (%d) %s", j->error.ec.value(), j->error.ec.message().c_str()); debug_log("on_piece_hashed, fatal disk error: (%d) %s", j->error.ec.value(), j->error.ec.message().c_str());
#endif #endif
auto_managed(false); auto_managed(false);
@ -2659,7 +2659,7 @@ namespace libtorrent
// we're using the piece hashes here, we need the torrent to be loaded // we're using the piece hashes here, we need the torrent to be loaded
if (!need_loaded()) if (!need_loaded())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("on_piece_hashed, need_loaded failed"); debug_log("on_piece_hashed, need_loaded failed");
#endif #endif
return; return;
@ -2705,7 +2705,7 @@ namespace libtorrent
// we paused the checking // we paused the checking
if (!should_check_files()) if (!should_check_files())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("on_piece_hashed, checking paused"); debug_log("on_piece_hashed, checking paused");
#endif #endif
return; return;
@ -2713,7 +2713,7 @@ namespace libtorrent
if (!need_loaded()) if (!need_loaded())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("on_piece_hashed, need_loaded failed"); debug_log("on_piece_hashed, need_loaded failed");
#endif #endif
return; return;
@ -2724,13 +2724,13 @@ namespace libtorrent
, disk_io_job::sequential_access | disk_io_job::volatile_read , disk_io_job::sequential_access | disk_io_job::volatile_read
, boost::bind(&torrent::on_piece_hashed , boost::bind(&torrent::on_piece_hashed
, shared_from_this(), _1), (void*)1); , shared_from_this(), _1), (void*)1);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("on_piece_hashed, m_checking_piece: %d", m_checking_piece); debug_log("on_piece_hashed, m_checking_piece: %d", m_checking_piece);
#endif #endif
return; return;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("on_piece_hashed, completed"); debug_log("on_piece_hashed, completed");
#endif #endif
// we're done checking! // we're done checking!
@ -2820,14 +2820,14 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (!m_ses.dht()) if (!m_ses.dht())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("DHT: no dht initialized"); debug_log("DHT: no dht initialized");
#endif #endif
return; return;
} }
if (!should_announce_dht()) if (!should_announce_dht())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (!m_ses.announce_dht()) if (!m_ses.announce_dht())
debug_log("DHT: no listen sockets"); debug_log("DHT: no listen sockets");
@ -2868,7 +2868,7 @@ namespace libtorrent
int port = m_ses.listen_port(); int port = m_ses.listen_port();
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("START DHT announce"); debug_log("START DHT announce");
m_dht_start_time = clock_type::now(); m_dht_start_time = clock_type::now();
#endif #endif
@ -2900,7 +2900,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("END DHT announce (%d ms) (%d peers)" debug_log("END DHT announce (%d ms) (%d peers)"
, int(total_milliseconds(clock_type::now() - m_dht_start_time)) , int(total_milliseconds(clock_type::now() - m_dht_start_time))
, int(peers.size())); , int(peers.size()));
@ -2935,7 +2935,7 @@ namespace libtorrent
if (m_trackers.empty()) if (m_trackers.empty())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** announce: no trackers"); debug_log("*** announce: no trackers");
#endif #endif
return; return;
@ -2947,7 +2947,7 @@ namespace libtorrent
// stopping // stopping
if (e != tracker_request::stopped && !m_announce_to_trackers) if (e != tracker_request::stopped && !m_announce_to_trackers)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** announce: event != stopped && !m_announce_to_trackers"); debug_log("*** announce: event != stopped && !m_announce_to_trackers");
#endif #endif
return; return;
@ -2956,7 +2956,7 @@ namespace libtorrent
// if we're not allowing peers, there's no point in announcing // if we're not allowing peers, there's no point in announcing
if (e != tracker_request::stopped && !m_allow_peers) if (e != tracker_request::stopped && !m_allow_peers)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** announce: event != stopped && !m_allow_peers"); debug_log("*** announce: event != stopped && !m_allow_peers");
#endif #endif
return; return;
@ -3008,7 +3008,7 @@ namespace libtorrent
for (int i = 0; i < int(m_trackers.size()); ++i) for (int i = 0; i < int(m_trackers.size()); ++i)
{ {
announce_entry& ae = m_trackers[i]; announce_entry& ae = m_trackers[i];
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** tracker: \"%s\" " debug_log("*** tracker: \"%s\" "
"[ tiers: %d trackers: %d" "[ tiers: %d trackers: %d"
" i->tier: %d tier: %d" " i->tier: %d tier: %d"
@ -3091,7 +3091,7 @@ namespace libtorrent
req.auth = tracker_login(); req.auth = tracker_login();
req.key = tracker_key(); req.key = tracker_key();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d" debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d"
, req.url.c_str() , req.url.c_str()
, (req.event==tracker_request::stopped?"stopped" , (req.event==tracker_request::stopped?"stopped"
@ -3269,7 +3269,7 @@ namespace libtorrent
if (resp.complete >= 0 && resp.incomplete >= 0) if (resp.complete >= 0 && resp.incomplete >= 0)
m_last_scrape = m_ses.session_time(); m_last_scrape = m_ses.session_time();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("TRACKER RESPONSE\n" debug_log("TRACKER RESPONSE\n"
"interval: %d\n" "interval: %d\n"
"external ip: %s\n" "external ip: %s\n"
@ -3409,7 +3409,7 @@ namespace libtorrent
?m_ses.get_ipv6_interface().address() ?m_ses.get_ipv6_interface().address()
:m_ses.get_ipv4_interface().address(); :m_ses.get_ipv4_interface().address();
announce_with_tracker(r.event, bind_interface); announce_with_tracker(r.event, bind_interface);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("announce again using %s as the bind interface" debug_log("announce again using %s as the bind interface"
, print_address(bind_interface).c_str()); , print_address(bind_interface).c_str());
#endif #endif
@ -3475,7 +3475,7 @@ namespace libtorrent
continue; continue;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
external_ip const& external = m_ses.external_address(); external_ip const& external = m_ses.external_address();
debug_log(" *** FOUND CONNECTION CANDIDATE [" debug_log(" *** FOUND CONNECTION CANDIDATE ["
" ip: %s rank: %u external: %s t: %d ]" " ip: %s rank: %u external: %s t: %d ]"
@ -3543,7 +3543,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (ec) if (ec)
debug_log("i2p_resolve error: %s", ec.message().c_str()); debug_log("i2p_resolve error: %s", ec.message().c_str());
#endif #endif
@ -3568,7 +3568,7 @@ namespace libtorrent
complete_async("torrent::on_peer_name_lookup"); complete_async("torrent::on_peer_name_lookup");
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (e) if (e)
debug_log("peer name lookup error: %s", e.message().c_str()); debug_log("peer name lookup error: %s", e.message().c_str());
#endif #endif
@ -3581,7 +3581,7 @@ namespace libtorrent
if (m_apply_ip_filter if (m_apply_ip_filter
&& m_ses.get_ip_filter().access(host.address()) & ip_filter::blocked) && m_ses.get_ip_filter().access(host.address()) & ip_filter::blocked)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
error_code ec; error_code ec;
debug_log("blocked ip from tracker: %s", host.address().to_string(ec).c_str()); debug_log("blocked ip from tracker: %s", host.address().to_string(ec).c_str());
#endif #endif
@ -3945,7 +3945,7 @@ namespace libtorrent
// -1: disk failure // -1: disk failure
// -2: piece failed check // -2: piece failed check
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** PIECE_FINISHED [ p: %d | chk: %s | size: %d ]" debug_log("*** PIECE_FINISHED [ p: %d | chk: %s | size: %d ]"
, j->piece, ((ret == 0) , j->piece, ((ret == 0)
?"passed":ret == -1 ?"passed":ret == -1
@ -4185,7 +4185,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
TORRENT_ASSERT(!m_picker->has_piece_passed(index)); TORRENT_ASSERT(!m_picker->has_piece_passed(index));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("PIECE_PASSED (%d)", num_passed()); debug_log("PIECE_PASSED (%d)", num_passed());
#endif #endif
@ -4260,7 +4260,7 @@ namespace libtorrent
for (peer_iterator p = m_connections.begin() for (peer_iterator p = m_connections.begin()
, end(m_connections.end()); p != end; ++p) , end(m_connections.end()); p != end; ++p)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
(*p)->peer_log(">>> PREDICTIVE_HAVE [ piece: %d expected in %d ms]" (*p)->peer_log(">>> PREDICTIVE_HAVE [ piece: %d expected in %d ms]"
, index, milliseconds); , index, milliseconds);
#endif #endif
@ -4402,11 +4402,11 @@ namespace libtorrent
if (p->connection) if (p->connection)
{ {
peer_connection* peer = static_cast<peer_connection*>(p->connection); peer_connection* peer = static_cast<peer_connection*>(p->connection);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** BANNING PEER: \"%s\" Too many corrupt pieces" debug_log("*** BANNING PEER: \"%s\" Too many corrupt pieces"
, print_endpoint(p->ip()).c_str()); , print_endpoint(p->ip()).c_str());
#endif #endif
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer->peer_log("*** BANNING PEER: Too many corrupt pieces"); peer->peer_log("*** BANNING PEER: Too many corrupt pieces");
#endif #endif
peer->disconnect(errors::too_many_corrupt_pieces, op_bittorrent); peer->disconnect(errors::too_many_corrupt_pieces, op_bittorrent);
@ -4764,7 +4764,7 @@ namespace libtorrent
error_code ec; error_code ec;
m_inactivity_timer.cancel(ec); m_inactivity_timer.cancel(ec);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_to_all_peers("ABORTING TORRENT"); log_to_all_peers("ABORTING TORRENT");
#endif #endif
@ -5513,7 +5513,7 @@ namespace libtorrent
p->update_interest(); p->update_interest();
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** UPDATE_PEER_INTEREST [ finished: %d was_finished %d ]" debug_log("*** UPDATE_PEER_INTEREST [ finished: %d was_finished %d ]"
, is_finished(), was_finished); , is_finished(), was_finished);
#endif #endif
@ -5997,7 +5997,7 @@ namespace libtorrent
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("failed to parse web seed url: %s", ec.message().c_str()); debug_log("failed to parse web seed url: %s", ec.message().c_str());
#endif #endif
if (m_ses.alerts().should_post<url_seed_alert>()) if (m_ses.alerts().should_post<url_seed_alert>())
@ -6012,7 +6012,7 @@ namespace libtorrent
if (web->peer_info.banned) if (web->peer_info.banned)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("banned web seed: %s", web->url.c_str()); debug_log("banned web seed: %s", web->url.c_str());
#endif #endif
if (m_ses.alerts().should_post<url_seed_alert>()) if (m_ses.alerts().should_post<url_seed_alert>())
@ -6082,7 +6082,7 @@ namespace libtorrent
return; return;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("resolving web seed: %s", web->url.c_str()); debug_log("resolving web seed: %s", web->url.c_str());
#endif #endif
@ -6090,7 +6090,7 @@ namespace libtorrent
if (ps.type == settings_pack::http if (ps.type == settings_pack::http
|| ps.type == settings_pack::http_pw) || ps.type == settings_pack::http_pw)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("resolving proxy for web seed: %s", web->url.c_str()); debug_log("resolving proxy for web seed: %s", web->url.c_str());
#endif #endif
@ -6108,7 +6108,7 @@ namespace libtorrent
} }
else else
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("resolving web seed: %s", web->url.c_str()); debug_log("resolving web seed: %s", web->url.c_str());
#endif #endif
@ -6128,7 +6128,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(web->resolving == true); TORRENT_ASSERT(web->resolving == true);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("completed resolve proxy hostname for: %s", web->url.c_str()); debug_log("completed resolve proxy hostname for: %s", web->url.c_str());
if (e) if (e)
debug_log("proxy name lookup error: %s", e.message().c_str()); debug_log("proxy name lookup error: %s", e.message().c_str());
@ -6137,7 +6137,7 @@ namespace libtorrent
if (web->removed) if (web->removed)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("removed web seed"); debug_log("removed web seed");
#endif #endif
remove_web_seed(web); remove_web_seed(web);
@ -6213,13 +6213,13 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(web->resolving == true); TORRENT_ASSERT(web->resolving == true);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("completed resolve: %s", web->url.c_str()); debug_log("completed resolve: %s", web->url.c_str());
#endif #endif
web->resolving = false; web->resolving = false;
if (web->removed) if (web->removed)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("removed web seed"); debug_log("removed web seed");
#endif #endif
remove_web_seed(web); remove_web_seed(web);
@ -6232,7 +6232,7 @@ namespace libtorrent
{ {
if (m_ses.alerts().should_post<url_seed_alert>()) if (m_ses.alerts().should_post<url_seed_alert>())
m_ses.alerts().emplace_alert<url_seed_alert>(get_handle(), web->url, e); m_ses.alerts().emplace_alert<url_seed_alert>(get_handle(), web->url, e);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** HOSTNAME LOOKUP FAILED: %s: (%d) %s" debug_log("*** HOSTNAME LOOKUP FAILED: %s: (%d) %s"
, web->url.c_str(), e.value(), e.message().c_str()); , web->url.c_str(), e.value(), e.message().c_str());
#endif #endif
@ -6248,7 +6248,7 @@ namespace libtorrent
// fill in the peer struct's address field // fill in the peer struct's address field
web->endpoints.push_back(tcp::endpoint(*i, port)); web->endpoints.push_back(tcp::endpoint(*i, port));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log(" -> %s", print_endpoint(tcp::endpoint(*i, port)).c_str()); debug_log(" -> %s", print_endpoint(tcp::endpoint(*i, port)).c_str());
#endif #endif
} }
@ -6414,7 +6414,7 @@ namespace libtorrent
, boost::int64_t(web->peer_info.prev_amount_upload) << 10); , boost::int64_t(web->peer_info.prev_amount_upload) << 10);
web->peer_info.prev_amount_download = 0; web->peer_info.prev_amount_download = 0;
web->peer_info.prev_amount_upload = 0; web->peer_info.prev_amount_upload = 0;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("web seed connection started: [%s] %s" debug_log("web seed connection started: [%s] %s"
, print_endpoint(a).c_str(), web->url.c_str()); , print_endpoint(a).c_str(), web->url.c_str());
#endif #endif
@ -6423,7 +6423,7 @@ namespace libtorrent
if (c->is_disconnecting()) return; if (c->is_disconnecting()) return;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("START queue peer [%p] (%d)", c.get(), num_peers()); debug_log("START queue peer [%p] (%d)", c.get(), num_peers());
#endif #endif
} }
@ -6431,7 +6431,7 @@ namespace libtorrent
{ {
TORRENT_DECLARE_DUMMY(std::exception, e); TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e; (void)e;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** PEER_ERROR: %s", e.what()); debug_log("*** PEER_ERROR: %s", e.what());
#endif #endif
c->disconnect(errors::no_error, op_bittorrent, 1); c->disconnect(errors::no_error, op_bittorrent, 1);
@ -6584,7 +6584,7 @@ namespace libtorrent
{ {
// unknown country! // unknown country!
p->set_country("!!"); p->set_country("!!");
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("IP \"%s\" was mapped to unknown country: %d" debug_log("IP \"%s\" was mapped to unknown country: %d"
, print_address(p->remote().address()).c_str(), country); , print_address(p->remote().address()).c_str(), country);
#endif #endif
@ -7730,7 +7730,7 @@ namespace libtorrent
if (!m_peer_list->new_connection(*p, m_ses.session_time(), &st)) if (!m_peer_list->new_connection(*p, m_ses.session_time(), &st))
{ {
peers_erased(st.erased); peers_erased(st.erased);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("CLOSING CONNECTION \"%s\" peer list full" debug_log("CLOSING CONNECTION \"%s\" peer list full"
, print_endpoint(p->remote()).c_str()); , print_endpoint(p->remote()).c_str());
#endif #endif
@ -7744,7 +7744,7 @@ namespace libtorrent
{ {
TORRENT_DECLARE_DUMMY(std::exception, e); TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e; (void)e;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("CLOSING CONNECTION \"%s\" caught exception: %s" debug_log("CLOSING CONNECTION \"%s\" caught exception: %s"
, print_endpoint(p->remote()).c_str(), e.what()); , print_endpoint(p->remote()).c_str(), e.what());
#endif #endif
@ -7762,7 +7762,7 @@ namespace libtorrent
++m_num_seeds; ++m_num_seeds;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("incoming peer (%d)", int(m_connections.size())); debug_log("incoming peer (%d)", int(m_connections.size()));
#endif #endif
@ -8038,7 +8038,7 @@ namespace libtorrent
TORRENT_ASSERT(p->associated_torrent().lock().get() == this); TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
if (p->upload_only()) if (p->upload_only())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
p->peer_log("*** SEED, CLOSING CONNECTION"); p->peer_log("*** SEED, CLOSING CONNECTION");
#endif #endif
seeds.push_back(p); seeds.push_back(p);
@ -8079,7 +8079,7 @@ namespace libtorrent
|| m_state == torrent_status::checking_files || m_state == torrent_status::checking_files
|| m_state == torrent_status::allocating) || m_state == torrent_status::allocating)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** RESUME_DOWNLOAD [ skipping, state: %d ]" debug_log("*** RESUME_DOWNLOAD [ skipping, state: %d ]"
, int(m_state)); , int(m_state));
#endif #endif
@ -8092,7 +8092,7 @@ namespace libtorrent
m_completed_time = 0; m_completed_time = 0;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** RESUME_DOWNLOAD"); debug_log("*** RESUME_DOWNLOAD");
#endif #endif
send_upload_only(); send_upload_only();
@ -8188,7 +8188,7 @@ namespace libtorrent
if (m_abort) if (m_abort)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("files_checked(), paused"); debug_log("files_checked(), paused");
#endif #endif
return; return;
@ -8279,7 +8279,7 @@ namespace libtorrent
pc->init(); pc->init();
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
pc->peer_log("*** ON_FILES_CHECKED"); pc->peer_log("*** ON_FILES_CHECKED");
#endif #endif
if (pc->is_interesting() && !pc->has_peer_choked()) if (pc->is_interesting() && !pc->has_peer_choked())
@ -8765,7 +8765,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_to_all_peers("DELETING FILES IN TORRENT"); log_to_all_peers("DELETING FILES IN TORRENT");
#endif #endif
@ -8838,7 +8838,7 @@ namespace libtorrent
alerts().emplace_alert<torrent_error_alert>(get_handle(), ec alerts().emplace_alert<torrent_error_alert>(get_handle(), ec
, resolve_filename(error_file)); , resolve_filename(error_file));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (ec) if (ec)
{ {
char buf[1024]; char buf[1024];
@ -9179,7 +9179,7 @@ namespace libtorrent
update_want_peers(); update_want_peers();
update_want_scrape(); update_want_scrape();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
log_to_all_peers("PAUSING TORRENT"); log_to_all_peers("PAUSING TORRENT");
#endif #endif
@ -9236,7 +9236,7 @@ namespace libtorrent
if (p->outstanding_bytes() > 0) if (p->outstanding_bytes() > 0)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
p->peer_log("*** CHOKING PEER: torrent graceful paused"); p->peer_log("*** CHOKING PEER: torrent graceful paused");
#endif #endif
// remove any un-sent requests from the queue // remove any un-sent requests from the queue
@ -9246,7 +9246,7 @@ namespace libtorrent
continue; continue;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
p->peer_log("*** CLOSING CONNECTION: torrent_paused"); p->peer_log("*** CLOSING CONNECTION: torrent_paused");
#endif #endif
p->disconnect(errors::torrent_paused, op_bittorrent); p->disconnect(errors::torrent_paused, op_bittorrent);
@ -9268,11 +9268,11 @@ namespace libtorrent
} }
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
void torrent::log_to_all_peers(char const* message) void torrent::log_to_all_peers(char const* message)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
for (peer_iterator i = m_connections.begin(); for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i) i != m_connections.end(); ++i)
{ {
@ -9397,7 +9397,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (!m_announcing) if (!m_announcing)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** update tracker timer: not announcing"); debug_log("*** update tracker timer: not announcing");
#endif #endif
return; return;
@ -9411,7 +9411,7 @@ namespace libtorrent
for (std::vector<announce_entry>::iterator i = m_trackers.begin() for (std::vector<announce_entry>::iterator i = m_trackers.begin()
, end(m_trackers.end()); i != end; ++i) , end(m_trackers.end()); i != end; ++i)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char msg[1000]; char msg[1000];
snprintf(msg, sizeof(msg), "*** tracker: \"%s\" " snprintf(msg, sizeof(msg), "*** tracker: \"%s\" "
"[ tiers: %d trackers: %d" "[ tiers: %d trackers: %d"
@ -9449,7 +9449,7 @@ namespace libtorrent
&& !settings().get_bool(settings_pack::announce_to_all_tiers)) break; && !settings().get_bool(settings_pack::announce_to_all_tiers)) break;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char msg[200]; char msg[200];
snprintf(msg, sizeof(msg), "*** update tracker timer: next_announce < now %d" snprintf(msg, sizeof(msg), "*** update tracker timer: next_announce < now %d"
" m_waiting_tracker: %d next_announce_in: %d" " m_waiting_tracker: %d next_announce_in: %d"
@ -9479,7 +9479,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (is_paused()) if (is_paused())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("start_announcing(), paused"); debug_log("start_announcing(), paused");
#endif #endif
return; return;
@ -9489,14 +9489,14 @@ namespace libtorrent
// request the metadata from // request the metadata from
if (!m_files_checked && valid_metadata()) if (!m_files_checked && valid_metadata())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("start_announcing(), files not checked (with valid metadata)"); debug_log("start_announcing(), files not checked (with valid metadata)");
#endif #endif
return; return;
} }
if (!m_torrent_file->is_valid() && !m_url.empty()) if (!m_torrent_file->is_valid() && !m_url.empty())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("start_announcing(), downloading URL"); debug_log("start_announcing(), downloading URL");
#endif #endif
return; return;
@ -9728,7 +9728,7 @@ namespace libtorrent
{ {
TORRENT_DECLARE_DUMMY(std::exception, e); TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e; (void)e;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
p->peer_log("*** ERROR %s", e.what()); p->peer_log("*** ERROR %s", e.what());
#endif #endif
p->disconnect(errors::no_error, op_bittorrent, 1); p->disconnect(errors::no_error, op_bittorrent, 1);
@ -10663,7 +10663,7 @@ namespace libtorrent
TORRENT_ASSERT(i->resolving == false); TORRENT_ASSERT(i->resolving == false);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("disconnect web seed: \"%s\"", i->url.c_str()); debug_log("disconnect web seed: \"%s\"", i->url.c_str());
#endif #endif
TORRENT_ASSERT(i->peer_info.connection); TORRENT_ASSERT(i->peer_info.connection);
@ -11237,7 +11237,7 @@ namespace libtorrent
m_state = s; m_state = s;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("set_state() %d", m_state); debug_log("set_state() %d", m_state);
#endif #endif
@ -11576,7 +11576,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** tracker error: (%d) %s %s", ec.value() debug_log("*** tracker error: (%d) %s %s", ec.value()
, ec.message().c_str(), msg.c_str()); , ec.message().c_str(), msg.c_str());
#endif #endif
@ -11589,7 +11589,7 @@ namespace libtorrent
ae->last_error = ec; ae->last_error = ec;
ae->message = msg; ae->message = msg;
int tracker_index = ae - &m_trackers[0]; int tracker_index = ae - &m_trackers[0];
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
debug_log("*** increment tracker fail count [%d]", ae->fails); debug_log("*** increment tracker fail count [%d]", ae->fails);
#endif #endif
// never talk to this tracker again // never talk to this tracker again
@ -11623,7 +11623,7 @@ namespace libtorrent
update_tracker_timer(aux::time_now()); update_tracker_timer(aux::time_now());
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
void torrent::debug_log(char const* fmt, ...) const void torrent::debug_log(char const* fmt, ...) const
{ {
if (!alerts().should_post<torrent_log_alert>()) return; if (!alerts().should_post<torrent_log_alert>()) return;

View File

@ -200,7 +200,7 @@ namespace libtorrent
, resolver_interface& resolver , resolver_interface& resolver
, struct ip_filter& ipf , struct ip_filter& ipf
, aux::session_settings const& sett , aux::session_settings const& sett
#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, aux::session_logger& ses , aux::session_logger& ses
#endif #endif
) )
@ -209,7 +209,7 @@ namespace libtorrent
, m_host_resolver(resolver) , m_host_resolver(resolver)
, m_settings(sett) , m_settings(sett)
, m_stats_counters(stats_counters) , m_stats_counters(stats_counters)
#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS #if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, m_ses(ses) , m_ses(ses)
#endif #endif
, m_abort(false) , m_abort(false)
@ -319,7 +319,7 @@ namespace libtorrent
// ignore packets smaller than 8 bytes // ignore packets smaller than 8 bytes
if (size < 8) if (size < 8)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_ses.session_log("incoming packet from %s, not a UDP tracker message " m_ses.session_log("incoming packet from %s, not a UDP tracker message "
"(%d Bytes)", print_endpoint(ep).c_str(), size); "(%d Bytes)", print_endpoint(ep).c_str(), size);
#endif #endif
@ -332,7 +332,7 @@ namespace libtorrent
if (i == m_udp_conns.end()) if (i == m_udp_conns.end())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_ses.session_log("incoming UDP tracker packet from %s has invalid " m_ses.session_log("incoming UDP tracker packet from %s has invalid "
"transaction ID (%" PRIu32 ")", print_endpoint(ep).c_str() "transaction ID (%" PRIu32 ")", print_endpoint(ep).c_str()
, transaction); , transaction);
@ -362,7 +362,7 @@ namespace libtorrent
if (i == m_udp_conns.end()) if (i == m_udp_conns.end())
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
// now, this may not have been meant to be a tracker response, // now, this may not have been meant to be a tracker response,
// but chances are pretty good, so it's probably worth logging // but chances are pretty good, so it's probably worth logging
m_ses.session_log("incoming UDP tracker packet from %s has invalid " m_ses.session_log("incoming UDP tracker packet from %s has invalid "
@ -395,7 +395,7 @@ namespace libtorrent
close_http_connections.push_back(*i); close_http_connections.push_back(*i);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> rc = c->requester(); boost::shared_ptr<request_callback> rc = c->requester();
if (rc) rc->debug_log("aborting: %s", req.url.c_str()); if (rc) rc->debug_log("aborting: %s", req.url.c_str());
#endif #endif
@ -410,7 +410,7 @@ namespace libtorrent
close_udp_connections.push_back(c); close_udp_connections.push_back(c);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> rc = c->requester(); boost::shared_ptr<request_callback> rc = c->requester();
if (rc) rc->debug_log("aborting: %s", req.url.c_str()); if (rc) rc->debug_log("aborting: %s", req.url.c_str());
#endif #endif

View File

@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/ip_filter.hpp" #include "libtorrent/ip_filter.hpp"
#include "libtorrent/aux_/time.hpp" #include "libtorrent/aux_/time.hpp"
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/socket_io.hpp" #include "libtorrent/socket_io.hpp"
#endif #endif
@ -126,7 +126,7 @@ namespace libtorrent
, boost::bind(&udp_tracker_connection::name_lookup , boost::bind(&udp_tracker_connection::name_lookup
, shared_from_this(), _1, _2, port)); , shared_from_this(), _1, _2, port));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]" if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]"
, hostname.c_str()); , hostname.c_str());
@ -155,7 +155,7 @@ namespace libtorrent
return; return;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ host: \"%s\" ip: \"%s\" | error: \"%s\" ]" if (cb) cb->debug_log("*** UDP_TRACKER [ host: \"%s\" ip: \"%s\" | error: \"%s\" ]"
, m_hostname.c_str(), print_endpoint(m_target).c_str(), ec.message().c_str()); , m_hostname.c_str(), print_endpoint(m_target).c_str(), ec.message().c_str());
@ -164,7 +164,7 @@ namespace libtorrent
// pick another target endpoint and try again // pick another target endpoint and try again
m_target = pick_target_endpoint(); m_target = pick_target_endpoint();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER trying next IP [ host: \"%s\" ip: \"%s\" ]" if (cb) cb->debug_log("*** UDP_TRACKER trying next IP [ host: \"%s\" ip: \"%s\" ]"
, m_hostname.c_str(), print_endpoint(m_target).c_str()); , m_hostname.c_str(), print_endpoint(m_target).c_str());
#endif #endif
@ -193,7 +193,7 @@ namespace libtorrent
} }
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]"); if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]");
#endif #endif
if (cancelled()) if (cancelled())
@ -220,7 +220,7 @@ namespace libtorrent
{ {
if (m_man.ip_filter().access(k->address()) == ip_filter::blocked) if (m_man.ip_filter().access(k->address()) == ip_filter::blocked)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: %s ]" if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: %s ]"
, print_address(k->address()).c_str()); , print_address(k->address()).c_str());
#endif #endif
@ -314,7 +314,7 @@ namespace libtorrent
return; return;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str()); if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
#endif #endif
@ -340,14 +340,14 @@ namespace libtorrent
bool udp_tracker_connection::on_receive(error_code const& e bool udp_tracker_connection::on_receive(error_code const& e
, udp::endpoint const& ep, char const* buf, int size) , udp::endpoint const& ep, char const* buf, int size)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
#endif #endif
// ignore resposes before we've sent any requests // ignore resposes before we've sent any requests
if (m_state == action_error) if (m_state == action_error)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("<== UDP_TRACKER [ m_action == error ]"); if (cb) cb->debug_log("<== UDP_TRACKER [ m_action == error ]");
#endif #endif
return false; return false;
@ -355,7 +355,7 @@ namespace libtorrent
if (m_abort) if (m_abort)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("<== UDP_TRACKER [ aborted]"); if (cb) cb->debug_log("<== UDP_TRACKER [ aborted]");
#endif #endif
return false; return false;
@ -367,7 +367,7 @@ namespace libtorrent
// the hostname, in which case this packet might be for us // the hostname, in which case this packet might be for us
if (!is_any(m_target.address()) && m_target != ep) if (!is_any(m_target.address()) && m_target != ep)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("<== UDP_TRACKER [ unexpected source IP: %s " if (cb) cb->debug_log("<== UDP_TRACKER [ unexpected source IP: %s "
"expected: %s ]" "expected: %s ]"
, print_endpoint(ep).c_str() , print_endpoint(ep).c_str()
@ -378,7 +378,7 @@ namespace libtorrent
if (e) fail(e); if (e) fail(e);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("<== UDP_TRACKER_PACKET [ size: %d ]", size); if (cb) cb->debug_log("<== UDP_TRACKER_PACKET [ size: %d ]", size);
#endif #endif
@ -389,14 +389,14 @@ namespace libtorrent
int action = detail::read_int32(ptr); int action = detail::read_int32(ptr);
boost::uint32_t transaction = detail::read_uint32(ptr); boost::uint32_t transaction = detail::read_uint32(ptr);
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action); if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action);
#endif #endif
// ignore packets with incorrect transaction id // ignore packets with incorrect transaction id
if (m_transaction_id != transaction) if (m_transaction_id != transaction)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ tid: %x ]" if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ tid: %x ]"
, int(transaction)); , int(transaction));
#endif #endif
@ -412,7 +412,7 @@ namespace libtorrent
// ignore packets that's not a response to our message // ignore packets that's not a response to our message
if (action != m_state) if (action != m_state)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ unexpected action: %d " if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ unexpected action: %d "
" expected: %d ]", action, m_state); " expected: %d ]", action, m_state);
#endif #endif
@ -421,7 +421,7 @@ namespace libtorrent
restart_read_timeout(); restart_read_timeout();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) if (cb)
cb->debug_log("*** UDP_TRACKER_RESPONSE [ tid: %x ]" cb->debug_log("*** UDP_TRACKER_RESPONSE [ tid: %x ]"
, int(transaction)); , int(transaction));
@ -480,13 +480,13 @@ namespace libtorrent
void udp_tracker_connection::send_udp_connect() void udp_tracker_connection::send_udp_connect()
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
#endif #endif
if (m_abort) if (m_abort)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("==> UDP_TRACKER_CONNECT [ skipped, m_abort ]"); if (cb) cb->debug_log("==> UDP_TRACKER_CONNECT [ skipped, m_abort ]");
#endif #endif
return; return;
@ -518,7 +518,7 @@ namespace libtorrent
++m_attempts; ++m_attempts;
if (ec) if (ec)
{ {
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("==> UDP_TRACKER_CONNECT [ failed: %s ]" if (cb) cb->debug_log("==> UDP_TRACKER_CONNECT [ failed: %s ]"
, ec.message().c_str()); , ec.message().c_str());
#endif #endif
@ -526,7 +526,7 @@ namespace libtorrent
return; return;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) if (cb)
{ {
char hex_ih[41]; char hex_ih[41];
@ -606,7 +606,7 @@ namespace libtorrent
} }
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) if (cb)
{ {
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
@ -755,7 +755,7 @@ namespace libtorrent
TORRENT_ASSERT(out - buf <= int(sizeof(buf))); TORRENT_ASSERT(out - buf <= int(sizeof(buf)));
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
if (cb) if (cb)
{ {

View File

@ -264,7 +264,7 @@ namespace libtorrent { namespace
TORRENT_ASSERT(type >= 0 && type <= 2); TORRENT_ASSERT(type >= 0 && type <= 2);
TORRENT_ASSERT(!m_pc.associated_torrent().expired()); TORRENT_ASSERT(!m_pc.associated_torrent().expired());
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
char const* names[] = {"request", "data", "dont-have"}; char const* names[] = {"request", "data", "dont-have"};
char const* n = ""; char const* n = "";
if (type >= 0 && type < 3) n = names[type]; if (type >= 0 && type < 3) n = names[type];
@ -330,7 +330,7 @@ namespace libtorrent { namespace
if (length > 17 * 1024) if (length > 17 * 1024)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== UT_METADATA [ packet too big %d ]", length); m_pc.peer_log("<== UT_METADATA [ packet too big %d ]", length);
#endif #endif
m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2); m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2);
@ -343,7 +343,7 @@ namespace libtorrent { namespace
entry msg = bdecode(body.begin, body.end, len); entry msg = bdecode(body.begin, body.end, len);
if (msg.type() != entry::dictionary_t) if (msg.type() != entry::dictionary_t)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== UT_METADATA [ not a dictionary ]"); m_pc.peer_log("<== UT_METADATA [ not a dictionary ]");
#endif #endif
m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2); m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2);
@ -355,7 +355,7 @@ namespace libtorrent { namespace
if (type_ent == 0 || type_ent->type() != entry::int_t if (type_ent == 0 || type_ent->type() != entry::int_t
|| piece_ent == 0 || piece_ent->type() != entry::int_t) || piece_ent == 0 || piece_ent->type() != entry::int_t)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== UT_METADATA [ missing or invalid keys ]"); m_pc.peer_log("<== UT_METADATA [ missing or invalid keys ]");
#endif #endif
m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2); m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2);
@ -364,7 +364,7 @@ namespace libtorrent { namespace
int type = type_ent->integer(); int type = type_ent->integer();
int piece = piece_ent->integer(); int piece = piece_ent->integer();
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== UT_METADATA [ type: %d | piece: %d ]", type, piece); m_pc.peer_log("<== UT_METADATA [ type: %d | piece: %d ]", type, piece);
#endif #endif
@ -375,7 +375,7 @@ namespace libtorrent { namespace
if (!m_torrent.valid_metadata() if (!m_torrent.valid_metadata()
|| piece < 0 || piece >= int(m_tp.get_metadata_size() + 16 * 1024 - 1)/(16*1024)) || piece < 0 || piece >= int(m_tp.get_metadata_size() + 16 * 1024 - 1)/(16*1024))
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("*** UT_METADATA [ have: %d invalid piece %d metadata size: %d ]" m_pc.peer_log("*** UT_METADATA [ have: %d invalid piece %d metadata size: %d ]"
, int(m_torrent.valid_metadata()), piece , int(m_torrent.valid_metadata()), piece
, int(m_tp.get_metadata_size())); , int(m_tp.get_metadata_size()));
@ -399,7 +399,7 @@ namespace libtorrent { namespace
// unwanted piece? // unwanted piece?
if (i == m_sent_requests.end()) if (i == m_sent_requests.end())
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("*** UT_METADATA [ UNWANTED / TIMED OUT ]"); m_pc.peer_log("*** UT_METADATA [ UNWANTED / TIMED OUT ]");
#endif #endif
return true; return true;
@ -547,7 +547,7 @@ namespace libtorrent { namespace
{ {
if (m_torrent.valid_metadata()) if (m_torrent.valid_metadata())
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ ALREADY HAVE METADATA ]"); source.m_pc.peer_log("*** UT_METADATA [ ALREADY HAVE METADATA ]");
#endif #endif
m_torrent.add_redundant_bytes(size, torrent::piece_unknown); m_torrent.add_redundant_bytes(size, torrent::piece_unknown);
@ -559,7 +559,7 @@ namespace libtorrent { namespace
// verify the total_size // verify the total_size
if (total_size <= 0 || total_size > m_torrent.session().settings().get_int(settings_pack::max_metadata_size)) if (total_size <= 0 || total_size > m_torrent.session().settings().get_int(settings_pack::max_metadata_size))
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ metadata size too big: %d ]", total_size); source.m_pc.peer_log("*** UT_METADATA [ metadata size too big: %d ]", total_size);
#endif #endif
// #error post alert // #error post alert
@ -573,7 +573,7 @@ namespace libtorrent { namespace
if (piece < 0 || piece >= int(m_requested_metadata.size())) if (piece < 0 || piece >= int(m_requested_metadata.size()))
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ piece: %d INVALID ]", piece); source.m_pc.peer_log("*** UT_METADATA [ piece: %d INVALID ]", piece);
#endif #endif
return false; return false;
@ -581,7 +581,7 @@ namespace libtorrent { namespace
if (total_size != m_metadata_size) if (total_size != m_metadata_size)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
source.m_pc.peer_log("*** UT_METADATA [ total_size: %d INCONSISTENT WITH: %d ]" source.m_pc.peer_log("*** UT_METADATA [ total_size: %d INCONSISTENT WITH: %d ]"
, total_size, m_metadata_size); , total_size, m_metadata_size);
#endif #endif

View File

@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/extensions/ut_pex.hpp" #include "libtorrent/extensions/ut_pex.hpp"
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/lazy_entry.hpp" #include "libtorrent/lazy_entry.hpp"
#endif #endif
@ -311,7 +311,7 @@ namespace libtorrent { namespace
bdecode_node p = pex_msg.dict_find_string("dropped"); bdecode_node p = pex_msg.dict_find_string("dropped");
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
int num_dropped = 0; int num_dropped = 0;
int num_added = 0; int num_added = 0;
if (p) num_dropped += p.string_length()/6; if (p) num_dropped += p.string_length()/6;
@ -333,7 +333,7 @@ namespace libtorrent { namespace
p = pex_msg.dict_find_string("added"); p = pex_msg.dict_find_string("added");
bdecode_node pf = pex_msg.dict_find_string("added.f"); bdecode_node pf = pex_msg.dict_find_string("added.f");
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (p) num_added += p.string_length() / 6; if (p) num_added += p.string_length() / 6;
#endif #endif
if (p && pf && pf.string_length() == p.string_length() / 6) if (p && pf && pf.string_length() == p.string_length() / 6)
@ -365,7 +365,7 @@ namespace libtorrent { namespace
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
bdecode_node p6 = pex_msg.dict_find("dropped6"); bdecode_node p6 = pex_msg.dict_find("dropped6");
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (p6) num_dropped += p6.string_length() / 18; if (p6) num_dropped += p6.string_length() / 18;
#endif #endif
if (p6 != 0 && p6.type() == bdecode_node::string_t) if (p6 != 0 && p6.type() == bdecode_node::string_t)
@ -383,7 +383,7 @@ namespace libtorrent { namespace
} }
p6 = pex_msg.dict_find("added6"); p6 = pex_msg.dict_find("added6");
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (p6) num_added += p6.string_length() / 18; if (p6) num_added += p6.string_length() / 18;
#endif #endif
bdecode_node p6f = pex_msg.dict_find("added6.f"); bdecode_node p6f = pex_msg.dict_find("added6.f");
@ -415,7 +415,7 @@ namespace libtorrent { namespace
} }
} }
#endif #endif
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("<== PEX [ dropped: %d added: %d ]" m_pc.peer_log("<== PEX [ dropped: %d added: %d ]"
, num_dropped, num_added); , num_dropped, num_added);
#endif #endif
@ -434,7 +434,7 @@ namespace libtorrent { namespace
time_point now = aux::time_now(); time_point now = aux::time_now();
if (now - seconds(60) < m_last_msg) if (now - seconds(60) < m_last_msg)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("*** PEX [ waiting: %d seconds to next msg ]" m_pc.peer_log("*** PEX [ waiting: %d seconds to next msg ]"
, total_seconds(seconds(60) - (now - m_last_msg))); , total_seconds(seconds(60) - (now - m_last_msg)));
#endif #endif
@ -452,7 +452,7 @@ namespace libtorrent { namespace
if (now - milliseconds(delay) < global_last) if (now - milliseconds(delay) < global_last)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("*** PEX [ global-wait: %d ]", total_seconds(milliseconds(delay) - (now - global_last))); m_pc.peer_log("*** PEX [ global-wait: %d ]", total_seconds(milliseconds(delay) - (now - global_last)));
#endif #endif
return; return;
@ -497,7 +497,7 @@ namespace libtorrent { namespace
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended); m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex); m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
bdecode_node m; bdecode_node m;
error_code ec; error_code ec;
int ret = bdecode(&pex_msg[0], &pex_msg[0] + pex_msg.size(), m, ec); int ret = bdecode(&pex_msg[0], &pex_msg[0] + pex_msg.size(), m, ec);
@ -605,7 +605,7 @@ namespace libtorrent { namespace
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended); m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex); m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size())); m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size()));
#endif #endif
} }

View File

@ -676,10 +676,6 @@ public:
bool m_stalled:1; bool m_stalled:1;
}; };
#if defined TORRENT_LOGGING
int socket_impl_size() { return sizeof(utp_socket_impl); }
#endif
utp_socket_impl* construct_utp_impl(boost::uint16_t recv_id utp_socket_impl* construct_utp_impl(boost::uint16_t recv_id
, boost::uint16_t send_id, void* userdata , boost::uint16_t send_id, void* userdata
, utp_socket_manager* sm) , utp_socket_manager* sm)

View File

@ -98,7 +98,7 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack
// into single larger ones // into single larger ones
request_large_blocks(true); request_large_blocks(true);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** web_peer_connection %s", m_url.c_str()); peer_log("*** web_peer_connection %s", m_url.c_str());
#endif #endif
} }
@ -122,7 +122,7 @@ void web_peer_connection::disconnect(error_code const& ec
if (op == op_sock_write && ec == boost::system::errc::broken_pipe) if (op == op_sock_write && ec == boost::system::errc::broken_pipe)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
// a write operation failed with broken-pipe. This typically happens // a write operation failed with broken-pipe. This typically happens
// with HTTP 1.0 servers that close their incoming channel of the TCP // with HTTP 1.0 servers that close their incoming channel of the TCP
// stream whenever they're done reading one full request. Instead of // stream whenever they're done reading one full request. Instead of
@ -156,7 +156,7 @@ void web_peer_connection::disconnect(error_code const& ec
if (!m_requests.empty() && !m_file_requests.empty() if (!m_requests.empty() && !m_file_requests.empty()
&& !m_piece.empty() && m_web) && !m_piece.empty() && m_web)
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** SAVE-RESTART-DATA: [ data: %d req: %d off: %d ]" peer_log("*** SAVE-RESTART-DATA: [ data: %d req: %d off: %d ]"
, int(m_piece.size()), int(m_requests.front().piece) , int(m_piece.size()), int(m_requests.front().piece)
, int(m_requests.front().start)); , int(m_requests.front().start));
@ -276,7 +276,7 @@ void web_peer_connection::write_request(peer_request const& r)
pr.piece = r.piece + request_offset / piece_size; pr.piece = r.piece + request_offset / piece_size;
m_requests.push_back(pr); m_requests.push_back(pr);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> REQUESTING [ piece: %d start: %d len: %d ]" peer_log("==> REQUESTING [ piece: %d start: %d len: %d ]"
, pr.piece, pr.start, pr.length); , pr.piece, pr.start, pr.length);
#endif #endif
@ -288,7 +288,7 @@ void web_peer_connection::write_request(peer_request const& r)
peer_request& front = m_requests.front(); peer_request& front = m_requests.front();
TORRENT_ASSERT(front.length > int(m_piece.size())); TORRENT_ASSERT(front.length > int(m_piece.size()));
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** RESTART-DATA: [ data: %d req: (%d, %d) ]" peer_log("*** RESTART-DATA: [ data: %d req: (%d, %d) ]"
, int(m_piece.size()), int(front.piece), int(front.start) , int(m_piece.size()), int(front.piece), int(front.start)
, int (front.start + front.length - 1)); , int (front.start + front.length - 1));
@ -395,7 +395,7 @@ void web_peer_connection::write_request(peer_request const& r)
} }
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("==> %s", request.c_str()); peer_log("==> %s", request.c_str());
#endif #endif
@ -441,7 +441,7 @@ bool web_peer_connection::maybe_harvest_block()
buffer::const_interval recv_buffer = m_recv_buffer.get(); buffer::const_interval recv_buffer = m_recv_buffer.get();
incoming_piece(front_request, &m_piece[0]); incoming_piece(front_request, &m_piece[0]);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]" peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]"
, front_request.piece, front_request.start, front_request.length); , front_request.piece, front_request.start, front_request.length);
#endif #endif
@ -518,7 +518,7 @@ void web_peer_connection::on_receive(error_code const& error
if (error) if (error)
{ {
received_bytes(0, bytes_transferred); received_bytes(0, bytes_transferred);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** web_peer_connection error: %s", error.message().c_str()); peer_log("*** web_peer_connection error: %s", error.message().c_str());
#endif #endif
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
@ -556,7 +556,7 @@ void web_peer_connection::on_receive(error_code const& error
if (failed) if (failed)
{ {
received_bytes(0, bytes_transferred); received_bytes(0, bytes_transferred);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** %s", std::string(recv_buffer.begin, recv_buffer.end).c_str()); peer_log("*** %s", std::string(recv_buffer.begin, recv_buffer.end).c_str());
#endif #endif
disconnect(errors::http_parse_error, op_bittorrent, 2); disconnect(errors::http_parse_error, op_bittorrent, 2);
@ -613,7 +613,7 @@ void web_peer_connection::on_receive(error_code const& error
m_web->supports_keepalive = false; m_web->supports_keepalive = false;
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** STATUS: %d %s", m_parser.status_code(), m_parser.message().c_str()); peer_log("*** STATUS: %d %s", m_parser.status_code(), m_parser.message().c_str());
std::multimap<std::string, std::string> const& headers = m_parser.headers(); std::multimap<std::string, std::string> const& headers = m_parser.headers();
for (std::multimap<std::string, std::string>::const_iterator i = headers.begin() for (std::multimap<std::string, std::string>::const_iterator i = headers.begin()
@ -711,7 +711,7 @@ void web_peer_connection::on_receive(error_code const& error
location = resolve_redirect_location(m_url, location); location = resolve_redirect_location(m_url, location);
} }
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** LOCATION: %s", location.c_str()); peer_log("*** LOCATION: %s", location.c_str());
#endif #endif
t->add_web_seed(location, web_seed_entry::url_seed, m_external_auth, m_extra_headers); t->add_web_seed(location, web_seed_entry::url_seed, m_external_auth, m_extra_headers);
@ -820,7 +820,7 @@ void web_peer_connection::on_receive(error_code const& error
} }
else else
{ {
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size); peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
#endif #endif
TORRENT_ASSERT(int(bytes_transferred) >= header_size - m_partial_chunk_header); TORRENT_ASSERT(int(bytes_transferred) >= header_size - m_partial_chunk_header);
@ -870,7 +870,7 @@ void web_peer_connection::on_receive(error_code const& error
TORRENT_ASSERT(m_block_pos >= 0); TORRENT_ASSERT(m_block_pos >= 0);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("*** payload_transferred: %d [ %d:%d = %d ]" peer_log("*** payload_transferred: %d [ %d:%d = %d ]"
, payload_transferred, front_request.piece , payload_transferred, front_request.piece
, front_request.start, front_request.length); , front_request.start, front_request.length);
@ -915,7 +915,7 @@ void web_peer_connection::on_receive(error_code const& error
, front_request.length - m_block_pos)); , front_request.length - m_block_pos));
received_bytes(0, bytes_transferred); received_bytes(0, bytes_transferred);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
std::vector<file_slice> sl = info.orig_files().map_block( std::vector<file_slice> sl = info.orig_files().map_block(
front_request.piece, front_request.start, front_request.start front_request.piece, front_request.start, front_request.start
+ front_request.length); + front_request.length);
@ -980,7 +980,7 @@ void web_peer_connection::on_receive(error_code const& error
incoming_piece_fragment(r.length); incoming_piece_fragment(r.length);
incoming_piece(r, recv_buffer.begin); incoming_piece(r, recv_buffer.begin);
#ifdef TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]" peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]"
, r.piece, r.start, r.length); , r.piece, r.start, r.length);
#endif #endif

View File

@ -71,7 +71,7 @@ struct mock_peer_connection : peer_connection_interface
virtual ~mock_peer_connection() {} virtual ~mock_peer_connection() {}
#if defined TORRENT_LOGGING #if !defined TORRENT_DISABLE_LOGGING
virtual void peer_log(char const* fmt, ...) const virtual void peer_log(char const* fmt, ...) const
{ {
va_list v; va_list v;
@ -130,7 +130,7 @@ struct mock_torrent
return true; return true;
} }
#if defined TORRENT_LOGGING #ifndef TORRENT_DISABLE_LOGGING
void debug_log(const char* fmt, ...) const void debug_log(const char* fmt, ...) const
{ {
va_list v; va_list v;