From 1faf2e201f46100fba59cc26b20cf20c8e7ba65e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 17 Apr 2015 01:15:33 +0000 Subject: [PATCH] inversed TORRENT_LOGGING build config to enable logging by default. It's now disabled by TORRENT_DISABLE_LOGGING --- CMakeLists.txt | 4 +- ChangeLog | 1 + Jamfile | 4 +- configure.ac | 4 +- docs/building.rst | 38 +-- include/libtorrent/alert.hpp | 20 +- include/libtorrent/alert_types.hpp | 12 +- include/libtorrent/aux_/session_impl.hpp | 8 +- include/libtorrent/aux_/session_interface.hpp | 10 +- include/libtorrent/lsd.hpp | 8 +- include/libtorrent/peer_connection.hpp | 10 +- .../libtorrent/peer_connection_interface.hpp | 2 +- include/libtorrent/torrent.hpp | 2 +- include/libtorrent/tracker_manager.hpp | 6 +- include/libtorrent/utp_stream.hpp | 4 - src/bt_peer_connection.cpp | 126 ++++---- src/http_seed_connection.cpp | 10 +- src/http_tracker_connection.cpp | 4 +- src/lsd.cpp | 24 +- src/lt_trackers.cpp | 18 +- src/metadata_transfer.cpp | 12 +- src/peer_connection.cpp | 306 +++++++++--------- src/peer_list.cpp | 8 +- src/request_blocks.cpp | 6 +- src/session_impl.cpp | 156 ++++----- src/smart_ban.cpp | 10 +- src/torrent.cpp | 184 +++++------ src/tracker_manager.cpp | 14 +- src/udp_tracker_connection.cpp | 44 +-- src/ut_metadata.cpp | 22 +- src/ut_pex.cpp | 20 +- src/utp_stream.cpp | 4 - src/web_peer_connection.cpp | 30 +- test/test_peer_list.cpp | 4 +- 34 files changed, 548 insertions(+), 587 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cf75121f..a1a47026a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,8 +190,8 @@ else() list(APPEND sources sha1) endif (encryption) -if (logging) - add_definitions(-DTORRENT_LOGGING) +if (NOT logging) + add_definitions(-DTORRENT_DISABLE_LOGGING) endif() foreach(s ${sources}) diff --git a/ChangeLog b/ChangeLog index 1efadb7f2..822d26bfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * enable logging build config by default (but alert mask disabled by default) * deprecated RSS API * experimental support for BEP 38, "mutable torrents" * replaced lazy_bdecode with a new bdecoder that's a lot more efficient diff --git a/Jamfile b/Jamfile index d7ba4befa..da251dd1b 100755 --- a/Jamfile +++ b/Jamfile @@ -393,8 +393,8 @@ feature.compose on : TORRENT_DISK_STATS ; feature simulate-slow-read : off on : composite propagated ; feature.compose on : TORRENT_SIMULATE_SLOW_READ ; -feature logging : off on : composite propagated link-incompatible ; -feature.compose on : TORRENT_LOGGING ; +feature logging : on off : composite propagated link-incompatible ; +feature.compose off : TORRENT_DISABLE_LOGGING ; feature dht : on off logging : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_DHT ; diff --git a/configure.ac b/configure.ac index 75d31e9e1..45121b219 100644 --- a/configure.ac +++ b/configure.ac @@ -379,11 +379,11 @@ AC_MSG_CHECKING([whether logging to disk should be enabled]) AS_CASE(["$ARG_ENABLE_LOGGING"], ["yes"|"default"], [ AC_MSG_RESULT([yes]) - AC_DEFINE([TORRENT_LOGGING],[1],[Define to enable support for logging alerts]) - COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_LOGGING " ], ["no"|"none"], [ 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_ERROR([Unknown option "$ARG_ENABLE_LOGGING". Use either "yes" or "no"])] diff --git a/docs/building.rst b/docs/building.rst index 1c0f98f66..6b93df1a6 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -249,10 +249,10 @@ Build features: | | * ``shared`` - links dynamically against the boost | | | libraries. | +--------------------------+----------------------------------------------------+ -| ``logging`` | * ``off`` - default. logging disabled. | -| | * ``on`` - logging alerts available, still need to | -| | be enabled by the alert mask. The reason logging | -| | is disabled by default is to keep the binary | +| ``logging`` | * ``off`` - logging alerts disabled. | +| | * ``on`` - default. logging alerts available, | +| | still need to be enabled by the alert mask. The | +| | reason to disable logging is to keep the binary | | | size down. | +--------------------------+----------------------------------------------------+ | ``dht`` | * ``on`` - build with support for tracker less | @@ -261,12 +261,6 @@ Build features: | | logging of the DHT protocol traffic. | | | * ``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 | | | * ``on`` - asserts are on, even in release mode | | | * ``off`` - asserts are disabled | @@ -356,12 +350,6 @@ Build features: | | API. Generates build errors when deprecated | | | 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 | | | linux and mingw and other posix platforms. | | | * ``on`` - force use of iconv | @@ -371,20 +359,6 @@ Build features: | ``i2p`` | * ``on`` - build with 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. 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. | | | * ``on`` - Enable logging of stack traces of | | | 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 | | | 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 | -| | peer_log_alert. Without this build flag, you | +| | peer_log_alert. With this build flag, you | | | cannot enable those alerts. | +----------------------------------------+-------------------------------------------------+ | ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant | diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 622b47d9e..59275631c 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -173,21 +173,21 @@ namespace libtorrent { rss_notification = 0x1000, #endif - // Enables debug logging alerts. These are only available when - // libtorrent is built with logging enabled (``TORRENT_LOGGING``). - // The alerts being posted are log_alert and are session wide. + // Enables debug logging alerts. These are available unless libtorrent + // was built with logging disabled (``TORRENT_DISABLE_LOGGING``). The + // alerts being posted are log_alert and are session wide. session_log_notification = 0x2000, - // Enables debug logging alerts for torrents. These are only available - // when libtorrent is built with logging enabled - // (``TORRENT_LOGGING``). The alerts being posted are + // Enables debug logging alerts for torrents. These are available + // unless libtorrent was built with logging disabled + // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are // torrent_log_alert and are torrent wide debug events. torrent_log_notification = 0x4000, - // Enables debug logging alerts for peers. These are only available - // when libtorrent is built with logging enabled - // (``TORRENT_LOGGING``). The alerts being posted are peer_log_alert - // and low-level peer events and messages. + // Enables debug logging alerts for peers. These are available unless + // libtorrent was built with logging disabled + // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are + // peer_log_alert and low-level peer events and messages. peer_log_notification = 0x8000, // The full bitmask, representing all available categories. diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 747c9352f..5f71bd442 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -2118,9 +2118,7 @@ namespace libtorrent // 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 // mask and is enabled by the ``alert::session_log_notification`` bit. - // Furhtermore, it's by default disabled as a build configuration. To - // enable, build libtorrent with logging support enabled (``logging=on`` - // with bjam or define ``TORRENT_LOGGING``). + // Furhtermore, it's by default disabled as a build configuration. struct TORRENT_EXPORT log_alert : alert { // internal @@ -2142,9 +2140,7 @@ namespace libtorrent // 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 // mask and is enabled by the ``alert::torrent_log_notification`` bit. By - // default it is disabled as a build configuration. To enable, build - // libtorrent with logging support enabled (``logging=on`` with bjam or - // define ``TORRENT_LOGGING``). + // default it is disabled as a build configuration. struct TORRENT_EXPORT torrent_log_alert : torrent_alert { // internal @@ -2166,9 +2162,7 @@ namespace libtorrent // 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 // mask and is enabled by the ``alert::peer_log_notification`` bit. By - // default it is disabled as a build configuration. To enable, build - // libtorrent with logging support enabled (``logging=on`` with bjam or - // define ``TORRENT_LOGGING``). + // default it is disabled as a build configuration. struct TORRENT_EXPORT peer_log_alert : peer_alert { // internal diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index c190ef20f..2c3f0d9e8 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -152,7 +152,7 @@ namespace libtorrent struct session_impl; struct session_settings; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING struct tracker_logger; #endif @@ -350,7 +350,7 @@ namespace libtorrent void on_port_map_log(char const* msg, int map_transport); void on_lsd_announce(error_code const& e); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING void on_lsd_log(char const* log); #endif @@ -1131,7 +1131,7 @@ namespace libtorrent // accumulated error 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_vlog(char const* fmt, va_list& va) const; @@ -1203,7 +1203,7 @@ namespace libtorrent #endif }; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING struct tracker_logger : request_callback { tracker_logger(session_interface& ses); diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index 93a8b2b4e..d41f6b916 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include #endif @@ -97,13 +97,13 @@ namespace libtorrent 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. // a release build with logging disabled (which is the default) will // not have this class at all struct session_logger { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING virtual void session_log(char const* fmt, ...) const = 0; virtual void session_vlog(char const* fmt, va_list& va) const = 0; #endif @@ -115,14 +115,14 @@ namespace libtorrent { namespace aux virtual bool is_posting_torrent_updates() const = 0; #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 // several smaller interfaces. Each subsystem could then limit the size // of the mock object to test it. struct session_interface : buffer_allocator_interface -#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS +#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS , session_logger #endif { diff --git a/include/libtorrent/lsd.hpp b/include/libtorrent/lsd.hpp index 406e05082..427f6b28e 100644 --- a/include/libtorrent/lsd.hpp +++ b/include/libtorrent/lsd.hpp @@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include #endif @@ -51,7 +51,7 @@ namespace libtorrent { typedef boost::function peer_callback_t; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING typedef boost::function log_callback_t; #endif @@ -59,7 +59,7 @@ class lsd : public boost::enable_shared_from_this { public: lsd(io_service& ios, peer_callback_t const& cb -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING , log_callback_t const& log #endif ); @@ -89,7 +89,7 @@ private: #if TORRENT_USE_IPV6 broadcast_socket m_socket6; #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_callback_t m_log_cb; void debug_log(char const* fmt, ...) const; #endif diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 087e56287..7f6d3dd96 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/debug.hpp" #endif @@ -414,7 +414,7 @@ namespace libtorrent void set_holepunch_mode() { m_holepunch_mode = true; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** HOLEPUNCH MODE ***"); #endif } @@ -550,11 +550,11 @@ namespace libtorrent void decrease_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; #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING time_point m_connect_time; time_point m_bitfield_time; time_point m_unchoke_time; @@ -650,7 +650,7 @@ namespace libtorrent virtual boost::optional downloading_piece_progress() const { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** downloading_piece_progress() dispatched to the base class!"); #endif return boost::optional(); diff --git a/include/libtorrent/peer_connection_interface.hpp b/include/libtorrent/peer_connection_interface.hpp index 610856766..9cfd0f5cf 100644 --- a/include/libtorrent/peer_connection_interface.hpp +++ b/include/libtorrent/peer_connection_interface.hpp @@ -62,7 +62,7 @@ namespace libtorrent virtual bool failed() const = 0; virtual stat const& statistics() 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; #endif }; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 98bd489f5..7e0a0cb38 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -1025,7 +1025,7 @@ namespace libtorrent time_t last_seen_complete() const { return m_last_seen_complete; } // LOGGING -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING virtual void debug_log(const char* fmt, ...) const; void log_to_all_peers(char const* message); time_point m_dht_start_time; diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index afc905b4b..3f164f24c 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -230,7 +230,7 @@ namespace libtorrent , const std::string& msg , int retry_interval) = 0; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING virtual void debug_log(const char* fmt, ...) const = 0; #endif }; @@ -336,7 +336,7 @@ namespace libtorrent , resolver_interface& resolver , struct ip_filter& ipf , aux::session_settings const& sett -#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS +#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS , aux::session_logger& ses #endif ); @@ -392,7 +392,7 @@ namespace libtorrent resolver_interface& m_host_resolver; aux::session_settings const& m_settings; counters& m_stats_counters; -#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS +#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS aux::session_logger& m_ses; #endif diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index 629d9c597..c51c099c7 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -161,10 +161,6 @@ void utp_send_ack(utp_socket_impl* s); void utp_socket_drained(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. // the reason why it's split up in a utp_stream class and // an implementation class is because the socket state has diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 7345c8f8b..d793ab6a9 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -125,7 +125,7 @@ namespace libtorrent , m_in_constructor(true) #endif { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** bt_peer_connection"); #endif @@ -173,7 +173,7 @@ namespace libtorrent if (t->graceful_pause()) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** ON_CONNECTED [ graceful-paused ]"); #endif disconnect(error_code(errors::torrent_paused), op_bittorrent); @@ -193,7 +193,7 @@ namespace libtorrent if (is_ssl(*get_socket())) out_enc_policy = settings_pack::pe_disabled; #endif -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char const* policy_name[] = {"forced", "enabled", "disabled"}; peer_log("*** outgoing encryption policy: %s", policy_name[out_enc_policy]); #endif @@ -254,7 +254,7 @@ namespace libtorrent void bt_peer_connection::on_metadata() { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** ON_METADATA"); #endif @@ -286,7 +286,7 @@ namespace libtorrent TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> DHT_PORT [ %d ]", listen_port); #endif char msg[] = {0,0,0,3, msg_dht_port, 0, 0}; @@ -302,7 +302,7 @@ namespace libtorrent INVARIANT_CHECK; TORRENT_ASSERT(m_sent_handshake); m_sent_bitfield = true; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> HAVE_ALL"); #endif char msg[] = {0,0,0,1, msg_have_all}; @@ -316,7 +316,7 @@ namespace libtorrent INVARIANT_CHECK; TORRENT_ASSERT(m_sent_handshake); m_sent_bitfield = true; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> HAVE_NONE"); #endif char msg[] = {0,0,0,1, msg_have_none}; @@ -333,7 +333,7 @@ namespace libtorrent if (!m_supports_fast) return; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]" , r.piece, r.start, r.length); #endif @@ -379,7 +379,7 @@ namespace libtorrent TORRENT_ASSERT(t); TORRENT_ASSERT(t->valid_metadata()); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> SUGGEST [ piece: %d num_peers: %d ]", piece , t->has_picker() ? t->picker().get_availability(piece) : -1); #endif @@ -444,7 +444,7 @@ namespace libtorrent TORRENT_ASSERT(!m_dh_key_exchange.get()); TORRENT_ASSERT(!m_sent_handshake); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (is_outgoing()) peer_log("*** initiating encrypted handshake"); #endif @@ -458,7 +458,7 @@ namespace libtorrent int pad_size = random() % 512; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" pad size: %d", pad_size); #endif @@ -472,7 +472,7 @@ namespace libtorrent std::generate(ptr, ptr + pad_size, random_byte); send_buffer(msg, buf_size); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" sent DH key"); #endif } @@ -536,7 +536,7 @@ namespace libtorrent if ((crypto_provide & settings_pack::pe_both) == 0) crypto_provide = settings_pack::pe_both; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char const* level[] = {"plaintext", "rc4", "plaintext rc4"}; peer_log(" crypto provide : [ %s ]" , level[crypto_provide-1]); @@ -576,7 +576,7 @@ namespace libtorrent else // 0x01 m_rc4_encrypted = false; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" crypto select : [ %s ]" , (crypto_select == 0x01) ? "plaintext" : "rc4"); #endif @@ -654,7 +654,7 @@ namespace libtorrent m_rc4->set_incoming_key(&remote_key[0], 20); m_rc4->set_outgoing_key(&local_key[0], 20); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" computed RC4 keys"); #endif } @@ -786,7 +786,7 @@ namespace libtorrent // we support FAST extension *(ptr + 7) |= 0x04; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::string bitmask; for (int k = 0; k < 8; ++k) { @@ -817,7 +817,7 @@ namespace libtorrent memcpy(ptr, &m_our_peer_id[0], 20); ptr += 20; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING { char hex_pid[41]; to_hex((char const*)&m_our_peer_id[0], 20, hex_pid); @@ -900,7 +900,7 @@ namespace libtorrent { INVARIANT_CHECK; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== KEEPALIVE"); #endif incoming_keepalive(); @@ -1240,7 +1240,7 @@ namespace libtorrent if (recv_pos < header_size) return; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING // peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d" // , p.piece, p.start, p.length); #endif @@ -1260,7 +1260,7 @@ namespace libtorrent if (merkle && list_size > 0) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size); #endif bdecode_node hash_list; @@ -1511,7 +1511,7 @@ namespace libtorrent #endif else { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING error_code ec; static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"}; peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]" @@ -1529,7 +1529,7 @@ namespace libtorrent { case hp_rendezvous: // rendezvous { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]" , print_address(ep.address()).c_str()); #endif @@ -1563,7 +1563,7 @@ namespace libtorrent torrent_peer* p = t->add_peer(ep, peer_info::pex); 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 ]" , print_address(ep.address()).c_str()); #endif @@ -1573,7 +1573,7 @@ namespace libtorrent } if (p->banned) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]" , print_address(ep.address()).c_str()); #endif @@ -1592,7 +1592,7 @@ namespace libtorrent t->update_want_peers(); if (p->connection) p->connection->set_holepunch_mode(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HOLEPUNCH [ msg:connect to: %s ]" , print_address(ep.address()).c_str()); #endif @@ -1600,7 +1600,7 @@ namespace libtorrent case hp_failed: { boost::uint32_t error = detail::read_uint32(ptr); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING error_code ec; char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"}; peer_log("<== HOLEPUNCH [ msg:failed error: %d msg: %s ]", error @@ -1609,7 +1609,7 @@ namespace libtorrent // #error deal with holepunch errors (void)error; } break; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING default: { error_code ec; @@ -1629,7 +1629,7 @@ namespace libtorrent else detail::write_uint8(1, ptr); detail::write_endpoint(ep, ptr); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING error_code ec; static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"}; 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_size() != 3) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== UPLOAD_ONLY [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size()); #endif return; } bool ul = detail::read_uint8(recv_buffer.begin) != 0; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false")); #endif set_upload_only(ul); @@ -1718,13 +1718,13 @@ namespace libtorrent if (!m_recv_buffer.packet_finished()) return; 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()); #endif return; } bool sm = detail::read_uint8(recv_buffer.begin) != 0; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== SHARE_MODE [ %s ]", (sm?"true":"false")); #endif set_share_mode(sm); @@ -1734,7 +1734,7 @@ namespace libtorrent if (extended_id == holepunch_msg) { if (!m_recv_buffer.packet_finished()) return; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HOLEPUNCH"); #endif on_holepunch(); @@ -1746,7 +1746,7 @@ namespace libtorrent if (!m_recv_buffer.packet_finished()) return; 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()); #endif return; @@ -1756,7 +1756,7 @@ namespace libtorrent return; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (m_recv_buffer.packet_finished()) peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]" , 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); 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" , ec.message().c_str(), pos); #endif return; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str()); #endif @@ -1981,7 +1981,7 @@ namespace libtorrent // connections, don't sent upload-only if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> UPLOAD_ONLY [ %d ]" , int(t->is_upload_only() && !t->super_seeding())); #endif @@ -2082,7 +2082,7 @@ namespace libtorrent if (t->super_seeding()) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" *** NOT SENDING BITFIELD, super seeding"); #endif if (m_supports_fast) write_have_none(); @@ -2113,7 +2113,7 @@ namespace libtorrent else if (t->num_have() == 0) { // don't send a bitfield if we don't have any pieces -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" *** NOT SENDING BITFIELD"); #endif m_sent_bitfield = true; @@ -2184,7 +2184,7 @@ namespace libtorrent , end(t->predictive_pieces().end()); i != end; ++i) msg[5 + *i / 8] |= (0x80 >> (*i & 7)); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::string bitfield_string; bitfield_string.resize(num_pieces); @@ -2205,7 +2205,7 @@ namespace libtorrent { for (int i = 0; i < num_lazy_pieces; ++i) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]); #endif write_have(lazy_pieces[i]); @@ -2324,7 +2324,7 @@ namespace libtorrent 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()); #endif } @@ -2538,7 +2538,7 @@ namespace libtorrent if (!m_enc_handler.is_recv_plaintext()) { int consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred); - #ifdef TORRENT_LOGGING + #ifndef TORRENT_DISABLE_LOGGING if (consumed + bytes_transferred > 0) peer_log("<== decrypted block [ s = %d ]", consumed + bytes_transferred); #endif @@ -2610,7 +2610,7 @@ namespace libtorrent return; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** received DH key"); #endif @@ -2709,7 +2709,7 @@ namespace libtorrent else { std::size_t bytes_processed = syncoffset + 20; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** sync point (hash) found at offset %d" , m_sync_bytes_read + bytes_processed - 20); #endif @@ -2758,7 +2758,7 @@ namespace libtorrent } 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"); #endif } @@ -2781,7 +2781,7 @@ namespace libtorrent return; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** verification constant found"); #endif m_state = read_pe_cryptofield; @@ -2845,7 +2845,7 @@ namespace libtorrent else { std::size_t bytes_processed = syncoffset + 8; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** sync point (verification constant) found at offset %d" , m_sync_bytes_read + bytes_processed - 8); #endif @@ -2880,7 +2880,7 @@ namespace libtorrent boost::uint32_t crypto_field = detail::read_uint32(recv_buffer.begin); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** crypto %s : [%s%s ]" , is_outgoing() ? "select" : "provide" , (crypto_field & 1) ? " plaintext" : "" @@ -2994,7 +2994,7 @@ namespace libtorrent return; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** len(IA) : %d", len_ia); #endif if (len_ia == 0) @@ -3040,7 +3040,7 @@ namespace libtorrent buffer::interval wr_buf = m_recv_buffer.mutable_buffer(); 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()); #endif @@ -3089,7 +3089,7 @@ namespace libtorrent wr_buf.begin += m_recv_buffer.packet_size(); rc4_decrypt(wr_buf.begin, wr_buf.left()); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** decrypted remaining %d bytes", wr_buf.left()); #endif } @@ -3130,14 +3130,14 @@ namespace libtorrent memcmp(recv_buffer.begin, protocol_string, 20) != 0) { #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** unrecognized protocol header"); #endif #ifdef TORRENT_USE_OPENSSL if (is_ssl(*get_socket())) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SSL peers are not allowed to use any other encryption"); #endif disconnect(errors::invalid_info_hash, op_bittorrent, 1); @@ -3163,7 +3163,7 @@ namespace libtorrent return; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** attempting encrypted connection"); #endif m_state = read_pe_dhkey; @@ -3191,7 +3191,7 @@ namespace libtorrent } #endif -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== BitTorrent protocol"); #endif } @@ -3211,7 +3211,7 @@ namespace libtorrent recv_buffer = m_recv_buffer.get(); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::string extensions; extensions.resize(8 * 8); for (int i=0; i < 8; ++i) @@ -3267,14 +3267,14 @@ namespace libtorrent if (!std::equal(recv_buffer.begin + 8, recv_buffer.begin + 28 , (const char*)t->torrent_file().info_hash().begin())) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** received invalid info_hash"); #endif disconnect(errors::invalid_info_hash, op_bittorrent, 1); return; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< info_hash received"); #endif } @@ -3310,7 +3310,7 @@ namespace libtorrent if (!m_recv_buffer.packet_finished()) return; recv_buffer = m_recv_buffer.get(); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING { char hex_pid[41]; to_hex(recv_buffer.begin, 20, hex_pid); @@ -3392,7 +3392,7 @@ namespace libtorrent if (m_supports_extensions) write_extensions(); #endif -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HANDSHAKE"); #endif // consider this a successful connection, reset the failcount @@ -3508,7 +3508,7 @@ namespace libtorrent int bt_peer_connection::hit_send_barrier(std::vector& iovec) { int next_barrier = m_enc_handler.encrypt(iovec); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (next_barrier != 0) peer_log("==> encrypted block [ s = %d ]", next_barrier); #endif diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index ac988a981..e30995bab 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -78,7 +78,7 @@ namespace libtorrent prefer_contiguous_blocks(blocks_per_piece); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** http_seed_connection"); #endif } @@ -194,7 +194,7 @@ namespace libtorrent request += "\r\n\r\n"; m_first_request = false; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> %s", request.c_str()); #endif @@ -213,7 +213,7 @@ namespace libtorrent if (error) { received_bytes(0, bytes_transferred); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** http_seed_connection error: %s", error.message().c_str()); #endif return; @@ -375,7 +375,7 @@ namespace libtorrent } else { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size); #endif 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()); if (retry_time <= 0) retry_time = 60; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** retrying in %d seconds", retry_time); #endif diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index d81c5d00f..3cfda6b39 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -232,7 +232,7 @@ namespace libtorrent // the url + 100 estimated header size sent_bytes(url.size() + 100); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); if (cb) @@ -266,7 +266,7 @@ namespace libtorrent ++i; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); if (cb) { diff --git a/src/lsd.cpp b/src/lsd.cpp index 2372701d9..c8ad8b3b3 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -66,7 +66,7 @@ namespace libtorrent static error_code ec; lsd::lsd(io_service& ios, peer_callback_t const& cb -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING , log_callback_t const& log #endif ) @@ -75,7 +75,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb #if TORRENT_USE_IPV6 , m_socket6(udp::endpoint(address_v6::from_string("ff15::efc0:988f", ec), 6771)) #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING , m_log_cb(log) #endif , 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 { 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); char msg[200]; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("==> LSD: ih: %s port: %u\n", ih_hex, listen_port); #endif @@ -157,7 +157,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast if (ec) { m_disabled = true; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** LSD: failed to send message: (%d) %s", ec.value() , ec.message().c_str()); #endif @@ -173,7 +173,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast if (ec) { m_disabled6 = true; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** LSD: failed to send message6: (%d) %s", ec.value() , ec.message().c_str()); #endif @@ -222,7 +222,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer if (!p.header_finished() || error) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("<== LSD: incomplete HTTP message"); #endif return; @@ -230,7 +230,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer if (p.method() != "bt-search") { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("<== LSD: invalid HTTP method: %s", p.method().c_str()); #endif return; @@ -239,7 +239,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer std::string const& port_str = p.header("port"); if (port_str.empty()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("<== LSD: invalid BT-SEARCH, missing port"); #endif 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); if (cookie == m_cookie) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("<== LSD: ignoring packet (cookie matched our own): %x == %x" , cookie, m_cookie); #endif @@ -274,7 +274,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer std::string const& ih_str = i->second; if (ih_str.size() != 40) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("<== LSD: invalid BT-SEARCH, invalid infohash: %s" , ih_str.c_str()); #endif @@ -286,7 +286,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer if (!ih.is_all_zeros() && port != 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("<== LSD: %s:%d ih: %s" , print_address(from.address()).c_str() , port, ih_str.c_str()); diff --git a/src/lt_trackers.cpp b/src/lt_trackers.cpp index 160e35f6b..409877bb7 100644 --- a/src/lt_trackers.cpp +++ b/src/lt_trackers.cpp @@ -209,7 +209,7 @@ namespace libtorrent { namespace // invalid tex message if (added == 0) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log(" <== LT_TEX [ NOT A DICTIONARY ]"); #endif return true; @@ -217,14 +217,14 @@ namespace libtorrent { namespace 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 " "from tex, don't add any more", m_tp.num_tex_trackers()); #endif return true; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::stringstream log_line; log_line << aux::time_now_string() << " <== LT_TEX [ " "added: "; @@ -259,7 +259,7 @@ namespace libtorrent { namespace if (m_tp.num_tex_trackers() >= 50) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_line << "**reached-limit** "; #endif break; @@ -271,11 +271,11 @@ namespace libtorrent { namespace if (m_torrent.add_tracker(e)) m_tp.increment_tracker_counter(); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_line << e.url << " "; #endif } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_line << "]\n"; m_pc.peer_log("%s", log_line.str().c_str()); #endif @@ -329,7 +329,7 @@ namespace libtorrent { namespace if (!m_torrent.valid_metadata() || m_torrent.torrent_file().priv()) return false; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::stringstream log_line; log_line << aux::time_now_string() << " ==> LT_TEX [ " "added: "; @@ -341,14 +341,14 @@ namespace libtorrent { namespace { if (!send_tracker(*i)) continue; added.push_back(i->url); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_line << i->url << " "; #endif } std::vector tex_msg; bencode(std::back_inserter(tex_msg), tex); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_line << "]"; m_pc.peer_log("%s", log_line.str().c_str()); #endif diff --git a/src/metadata_transfer.cpp b/src/metadata_transfer.cpp index 11f5d5fe9..f442ee885 100644 --- a/src/metadata_transfer.cpp +++ b/src/metadata_transfer.cpp @@ -304,7 +304,7 @@ namespace libtorrent { namespace // abort if the peer doesn't support the metadata extension if (m_message_index == 0) return; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log("==> METADATA_REQUEST [ start: %d | size: %d ]\n" , start, size); #endif @@ -342,7 +342,7 @@ namespace libtorrent { namespace char msg[15]; 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 ]" , req.first, req.second, offset.first, offset.second); #endif @@ -363,7 +363,7 @@ namespace libtorrent { namespace } else { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log("==> DONT HAVE METADATA\n"); #endif char msg[4+3]; @@ -404,7 +404,7 @@ namespace libtorrent { namespace int start = detail::read_uint8(body.begin); 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" , start, size); #endif @@ -427,7 +427,7 @@ namespace libtorrent { namespace int offset = detail::read_int32(body.begin); 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 ]" ,total_size, offset, data_size); #endif @@ -470,7 +470,7 @@ namespace libtorrent { namespace if (m_waiting_metadata_request) m_tp.cancel_metadata_request(m_last_metadata_request); m_waiting_metadata_request = false; -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log("<== DONT HAVE METADATA\n"); #endif break; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 9b369109e..838e84dda 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include // for va_start, va_end #include // for vsnprintf #include "libtorrent/socket_io.hpp" @@ -239,7 +239,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES std::fill(m_country, m_country + 2, 0); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING error_code ec; TORRENT_ASSERT(m_socket->remote_endpoint(ec) == m_remote || ec); tcp::endpoint local_ep = m_socket->local_endpoint(ec); @@ -346,7 +346,7 @@ namespace libtorrent if (m_remote.address().is_v4() && m_settings.get_int(settings_pack::peer_tos) != 0) { m_socket->set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_settings.get_int(settings_pack::peer_tos), ec.message().c_str()); #endif } @@ -358,13 +358,13 @@ namespace libtorrent #endif } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SET_PEER_CLASS [ a: %s ]", print_address(m_remote.address()).c_str()); #endif m_ses.set_peer_classes(this, m_remote.address(), m_socket->type()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING for (int i = 0; i < num_classes(); ++i) { peer_log("*** CLASS [ %s ]", m_ses.peer_classes().at(class_at(i))->label.c_str()); @@ -379,7 +379,7 @@ namespace libtorrent // if this is an incoming connection, we're done here if (!m_connecting) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> OPEN [ protocol: %s ]", (m_remote.address().is_v4()?"IPv4":"IPv6")); #endif error_code ec; @@ -392,7 +392,7 @@ namespace libtorrent tcp::endpoint bound_ip = m_ses.bind_outgoing_socket(*m_socket , m_remote.address(), ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> BIND [ dst: %s ec: %s ]", print_endpoint(bound_ip).c_str() , ec.message().c_str()); #endif @@ -402,14 +402,14 @@ namespace libtorrent return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> ASYNC_CONNECT [ dst: %s ]", print_endpoint(m_remote).c_str()); #endif #if defined TORRENT_ASIO_DEBUGGING add_outstanding_async("peer_connection::on_connection_complete"); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (t) t->debug_log("START connect [%p] (%d)", this, int(t->num_peers())); #endif @@ -425,7 +425,7 @@ namespace libtorrent t->alerts().emplace_alert( t->get_handle(), remote(), pid(), m_socket->type()); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** LOCAL ENDPOINT[ e: %s ]", print_endpoint(m_socket->local_endpoint(ec)).c_str()); #endif } @@ -460,14 +460,14 @@ namespace libtorrent // flag will be updated once they are. if (m_have_piece.size() == 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** UPDATE_INTEREST [ connections not initialized ]"); #endif return; } if (!t->ready_for_connections()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** UPDATE_INTEREST [ not ready for connections ]"); #endif return; @@ -486,7 +486,7 @@ namespace libtorrent && !p.has_piece_passed(j)) { interested = true; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** UPDATE_INTEREST [ interesting, piece: %d ]", j); #endif break; @@ -494,7 +494,7 @@ namespace libtorrent } } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (!interested) peer_log("*** UPDATE_INTEREST [ not interesting ]"); #endif @@ -507,7 +507,7 @@ namespace libtorrent disconnect_if_redundant(); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING void peer_connection::peer_log(char const* fmt, ...) const { TORRENT_ASSERT(is_single_thread()); @@ -559,7 +559,7 @@ namespace libtorrent if (t->super_seeding()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SKIPPING ALLOWED SET BECAUSE OF SUPER SEEDING"); #endif return; @@ -567,7 +567,7 @@ namespace libtorrent if (upload_only()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SKIPPING ALLOWED SET BECAUSE PEER IS UPLOAD ONLY"); #endif return; @@ -589,7 +589,7 @@ namespace libtorrent // that the peer already has if (has_piece(i)) continue; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> ALLOWED_FAST [ %d ]", i); #endif write_allow_fast(i); @@ -633,7 +633,7 @@ namespace libtorrent if (std::find(m_accept_fast.begin(), m_accept_fast.end(), piece) == m_accept_fast.end()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> ALLOWED_FAST [ %d ]", piece); #endif write_allow_fast(piece); @@ -711,7 +711,7 @@ namespace libtorrent if (m_num_pieces == int(m_have_piece.size())) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** THIS IS A SEED [ p: %p ]", m_peer_info); #endif @@ -815,7 +815,7 @@ namespace libtorrent m_extensions.clear(); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** CONNECTION CLOSED"); #endif TORRENT_ASSERT(m_request_queue.empty()); @@ -899,7 +899,7 @@ namespace libtorrent // dont announce during handshake if (in_handshake()) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< RECEIVED [ piece: %d ]", index); #endif @@ -942,7 +942,7 @@ namespace libtorrent // to peers that already have the piece if (!m_settings.get_bool(settings_pack::send_redundant_have)) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> HAVE [ piece: %d ] SUPRESSED", index); #endif return; @@ -951,7 +951,7 @@ namespace libtorrent if (disconnect_if_redundant()) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> HAVE [ piece: %d ]", index); #endif write_have(index); @@ -1164,7 +1164,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_connect_time = clock_type::now(); peer_log("*** attached to torrent"); #endif @@ -1176,7 +1176,7 @@ namespace libtorrent if (t && t->is_aborted()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** the torrent has been aborted"); #endif t.reset(); @@ -1185,7 +1185,7 @@ namespace libtorrent if (!t) { t = m_ses.delay_load_torrent(ih, this); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (t) peer_log("*** Delay loaded torrent: %s:", to_hex(ih.to_string()).c_str()); #endif @@ -1194,7 +1194,7 @@ namespace libtorrent if (!t) { // we couldn't find the torrent! -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** couldn't find a torrent with the given info_hash: %s torrents:", to_hex(ih.to_string()).c_str()); #endif @@ -1226,7 +1226,7 @@ namespace libtorrent // and inconing_starts_queued_torrents is true // torrents that have errors should always reject // incoming peers -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("rejected connection to paused torrent"); #endif disconnect(errors::torrent_paused, op_bittorrent, 2); @@ -1240,7 +1240,7 @@ namespace libtorrent { // the torrent is an i2p torrent, the peer is a regular peer // and we don't allow mixed mode. Disconnect the peer. -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("rejected regular connection to i2p torrent"); #endif disconnect(errors::peer_banned, op_bittorrent, 2); @@ -1321,7 +1321,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== KEEPALIVE"); #endif } @@ -1355,7 +1355,7 @@ namespace libtorrent #endif if (is_disconnecting()) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== CHOKE"); #endif if (m_peer_choked == false) @@ -1414,7 +1414,7 @@ namespace libtorrent boost::shared_ptr t = m_torrent.lock(); TORRENT_ASSERT(t); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== REJECT_PIECE [ piece: %d | s: %x | l: %x ]" , r.piece, r.start, r.length); #endif @@ -1463,7 +1463,7 @@ namespace libtorrent check_invariant(); #endif } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING else { peer_log("*** PIECE NOT IN REQUEST QUEUE"); @@ -1503,7 +1503,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== SUGGEST_PIECE [ piece: %d ]", index); #endif boost::shared_ptr t = m_torrent.lock(); @@ -1520,7 +1520,7 @@ namespace libtorrent if (is_disconnecting()) return; if (index < 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== INVALID_SUGGEST_PIECE [ %d ]", index); #endif return; @@ -1530,7 +1530,7 @@ namespace libtorrent { if (index >= int(m_have_piece.size())) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== INVALID_SUGGEST [ %d | s: %d ]" , index, int(m_have_piece.size())); #endif @@ -1548,7 +1548,7 @@ namespace libtorrent m_suggested_pieces.push_back(index); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("** SUGGEST_PIECE [ piece: %d added to set: %d ]", index, int(m_suggested_pieces.size())); #endif } @@ -1565,7 +1565,7 @@ namespace libtorrent boost::shared_ptr t = m_torrent.lock(); TORRENT_ASSERT(t); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_unchoke_time = clock_type::now(); t->debug_log("UNCHOKE [%p] (%d ms)", this, int(total_milliseconds(m_unchoke_time - m_bitfield_time))); #endif @@ -1578,7 +1578,7 @@ namespace libtorrent } #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== UNCHOKE"); #endif if (m_peer_choked) @@ -1616,7 +1616,7 @@ namespace libtorrent } #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== INTERESTED"); #endif if (m_peer_interested == false) @@ -1633,7 +1633,7 @@ namespace libtorrent if (t->graceful_pause()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("DID NOT UNCHOKE [ graceful pause mode ]"); #endif return; @@ -1649,7 +1649,7 @@ namespace libtorrent // when sending the interested message. If the other end's client // has this problem, sending another unchoke here will kick it // to react to the fact that it's unchoked. -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("SENDING REDUNDANT UNCHOKE"); #endif write_unchoke(); @@ -1664,7 +1664,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); if (ignore_unchoke_slots()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("ABOUT TO UNCHOKE [ peer ignores unchoke slots ]"); #endif // if this peer is expempted from the choker @@ -1689,7 +1689,7 @@ namespace libtorrent t->unchoke_peer(*this); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING else { peer_log("DID NOT UNCHOKE [ the number of uploads (%d) " @@ -1718,7 +1718,7 @@ namespace libtorrent m_became_uninterested = aux::time_now(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== NOT_INTERESTED"); #endif if (m_peer_interested) @@ -1782,7 +1782,7 @@ namespace libtorrent // probably omitted, which is the same as 'have_none' if (!m_bitfield_received) incoming_have_none(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HAVE [ piece: %d ]", index); #endif @@ -1809,7 +1809,7 @@ namespace libtorrent // if we got an invalid message, abort if (index >= int(m_have_piece.size()) || index < 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** ERROR: [ have-metadata have_piece.size: %d ]", index, int(m_have_piece.size())); #endif disconnect(errors::invalid_have, op_bittorrent, 2); @@ -1832,7 +1832,7 @@ namespace libtorrent if (m_have_piece[index]) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" got redundant HAVE message for index: %d", index); #endif return; @@ -1868,7 +1868,7 @@ namespace libtorrent // decrement the piece count without first incrementing it if (is_seed()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** THIS IS A SEED [ p: %p ]", m_peer_info); #endif @@ -1938,7 +1938,7 @@ namespace libtorrent if (is_disconnecting()) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== DONT_HAVE [ piece: %d ]", index); #endif @@ -1951,7 +1951,7 @@ namespace libtorrent if (!m_have_piece[index]) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(" got redundant DONT_HAVE message for index: %d", index); #endif return; @@ -1996,7 +1996,7 @@ namespace libtorrent if (is_disconnecting()) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::string bitfield_str; bitfield_str.resize(bits.size()); for (int i = 0; i < int(bits.size()); ++i) @@ -2023,7 +2023,7 @@ namespace libtorrent m_bitfield_received = true; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_bitfield_time = clock_type::now(); t->debug_log("HANDSHAKE [%p] (%d ms)", this, int(total_milliseconds(m_bitfield_time - m_connect_time))); #endif @@ -2033,7 +2033,7 @@ namespace libtorrent // (since it doesn't exist yet) if (!t->ready_for_connections()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (m_num_pieces == int(bits.size())) peer_log("*** THIS IS A SEED [ p: %p ]", m_peer_info); #endif @@ -2053,7 +2053,7 @@ namespace libtorrent int num_pieces = bits.count(); if (num_pieces == int(m_have_piece.size())) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** THIS IS A SEED [ p: %p ]", m_peer_info); #endif @@ -2117,7 +2117,7 @@ namespace libtorrent if (m_upload_only && t->is_upload_only() && can_disconnect(error_code(errors::upload_upload_connection, get_libtorrent_category()))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** the peer is upload-only and our torrent is also upload-only"); #endif disconnect(errors::upload_upload_connection, op_bittorrent); @@ -2130,7 +2130,7 @@ namespace libtorrent && t->are_files_checked() && can_disconnect(error_code(errors::uninteresting_upload_peer, get_libtorrent_category()))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** the peer is upload-only and we're not interested in it"); #endif disconnect(errors::uninteresting_upload_peer, op_bittorrent); @@ -2167,7 +2167,7 @@ namespace libtorrent m_counters.inc_stats_counter(counters::piece_requests); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== REQUEST [ piece: %d s: %x l: %x ]" , r.piece, r.start, r.length); #endif @@ -2177,7 +2177,7 @@ namespace libtorrent { m_counters.inc_stats_counter(counters::invalid_piece_requests); ++m_num_invalid_requests; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** INVALID_REQUEST [ piece not superseeded " "i: %d t: %d n: %d h: %d ss1: %d ss2: %d ]" , m_peer_interested @@ -2218,7 +2218,7 @@ namespace libtorrent m_counters.inc_stats_counter(counters::invalid_piece_requests); // if we don't have valid metadata yet, // we shouldn't get a request -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** INVALID_REQUEST [ we don't have metadata yet ]"); peer_log("==> REJECT_PIECE [ piece: %d | s: %x | l: %x ] no metadata" , r.piece, r.start, r.length); @@ -2234,7 +2234,7 @@ namespace libtorrent // memory consumption. // ignore requests if the client // is making too many of them. -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** INVALID_REQUEST [ incoming request queue full %d ]" , int(m_requests.size())); peer_log("==> REJECT_PIECE [ piece: %d | s: %x | l: %x ] too many requests" @@ -2251,7 +2251,7 @@ namespace libtorrent if (!m_peer_interested) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** INVALID_REQUEST [ peer is not interested " " t: %d n: %d h: %d block_limit: %d ]" , int(t->torrent_file().piece_size(r.piece)) @@ -2287,7 +2287,7 @@ namespace libtorrent { m_counters.inc_stats_counter(counters::invalid_piece_requests); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** INVALID_REQUEST [ " "i: %d t: %d n: %d h: %d block_limit: %d ]" , m_peer_interested @@ -2324,7 +2324,7 @@ namespace libtorrent disconnect(errors::too_many_requests_when_choked, op_bittorrent, 2); return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> CHOKE"); #endif write_choke(); @@ -2349,7 +2349,7 @@ namespace libtorrent if (m_choked && fast_idx == -1) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** REJECTING REQUEST [ peer choked and piece not in allowed fast set ]"); peer_log(" ==> REJECT_PIECE [ piece: %d | s: %d | l: %d ] peer choked" , r.piece, r.start, r.length); @@ -2441,7 +2441,7 @@ namespace libtorrent if (!verify_piece(r)) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** INVALID_PIECE [ piece: %d s: %d l: %d ]" , r.piece, r.start, r.length); #endif @@ -2488,7 +2488,7 @@ namespace libtorrent t->alerts().emplace_alert(t->get_handle() , m_remote, m_peer_id, int(b.block_index), int(b.piece_index)); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** The block we just got was not in the request queue ***"); #endif TORRENT_ASSERT(m_download_queue.front().block == b); @@ -2550,7 +2550,7 @@ namespace libtorrent if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0) m_counters.inc_stats_counter(counters::num_peers_down_disk); m_channel_state[download_channel] |= peer_info::bw_disk; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** exceeded disk buffer watermark"); #endif } @@ -2612,7 +2612,7 @@ namespace libtorrent #endif #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING hasher h; h.update(data.get(), p.length); peer_log("<== PIECE [ piece: %d | s: %x | l: %x | ds: %d | qs: %d | q: %d | hash: %s ]" @@ -2674,7 +2674,7 @@ namespace libtorrent , m_remote, m_peer_id, int(block_finished.block_index) , int(block_finished.piece_index)); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** The block we just got was not in the request queue ***"); #endif #if TORRENT_USE_ASSERTS @@ -2717,7 +2717,7 @@ namespace libtorrent if (m_disconnecting) return; m_request_time.add_sample(total_milliseconds(now - m_requested)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** REQUEST-TIME (%d +- %d ms)" , m_request_time.mean(), m_request_time.avg_deviation()); #endif @@ -2748,7 +2748,7 @@ namespace libtorrent } } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING t->debug_log("PIECE [%p] (%d ms) (%d)", this , int(total_milliseconds(clock_type::now() - m_unchoke_time)), t->num_have()); @@ -2787,7 +2787,7 @@ namespace libtorrent } m_request_time.add_sample(total_milliseconds(now - m_requested)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** REQUEST-TIME (%d +- %d ms)" , m_request_time.mean(), m_request_time.avg_deviation()); #endif @@ -2885,7 +2885,7 @@ namespace libtorrent torrent_ref_holder h(t.get(), "async_write"); if (t) t->dec_refcount("async_write"); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** FILE ASYNC WRITE COMPLETE [ ret: %d | piece: %d | s: %x | l: %x | e: %s ]" , j->ret, p.piece, p.start, p.length, j->error.ec.message().c_str()); #endif @@ -2993,7 +2993,7 @@ namespace libtorrent #endif if (is_disconnecting()) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== CANCEL [ piece: %d | s: %x | l: %x ]", r.piece, r.start, r.length); #endif @@ -3008,7 +3008,7 @@ namespace libtorrent if (m_requests.empty()) m_counters.inc_stats_counter(counters::num_peers_up_requests, -1); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> REJECT_PIECE [ piece: %d s: %x l: %x ] cancelled" , r.piece , r.start , r.length); #endif @@ -3021,7 +3021,7 @@ namespace libtorrent // queue entry around, mark it as having been requested from // disk and once the disk job comes back, discard it if it has // been cancelled. Maybe even be able to cancel disk jobs? -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** GOT CANCEL NOT IN THE QUEUE"); #endif } @@ -3036,7 +3036,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== DHT_PORT [ p: %d ]", listen_port); #endif #ifndef TORRENT_DISABLE_DHT @@ -3061,7 +3061,7 @@ namespace libtorrent // this function may end up doing that TORRENT_ASSERT(m_in_constructor == false); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HAVE_ALL"); #endif @@ -3079,7 +3079,7 @@ namespace libtorrent m_have_all = true; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** THIS IS A SEED [ p: %p ]", m_peer_info); #endif @@ -3087,7 +3087,7 @@ namespace libtorrent m_upload_only = true; m_bitfield_received = true; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_bitfield_time = clock_type::now(); t->debug_log("HANDSHAKE [%p] (%d ms)", this, int(total_milliseconds(m_bitfield_time - m_connect_time))); #endif @@ -3137,7 +3137,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== HAVE_NONE"); #endif @@ -3159,7 +3159,7 @@ namespace libtorrent t->set_seed(m_peer_info, false); m_bitfield_received = true; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_bitfield_time = clock_type::now(); t->debug_log("HANDSHAKE [%p] (%d ms)", this, int(total_milliseconds(m_bitfield_time - m_connect_time))); #endif @@ -3188,7 +3188,7 @@ namespace libtorrent boost::shared_ptr t = m_torrent.lock(); TORRENT_ASSERT(t); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING { time_point now = clock_type::now(); t->debug_log("ALLOW FAST [%p] (%d ms)", this, int(total_milliseconds(now - m_connect_time))); @@ -3207,7 +3207,7 @@ namespace libtorrent if (is_disconnecting()) return; if (index < 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== INVALID_ALLOWED_FAST [ %d ]", index); #endif return; @@ -3217,7 +3217,7 @@ namespace libtorrent { if (index >= int(m_have_piece.size())) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== INVALID_ALLOWED_FAST [ %d | s: %d ]" , index, int(m_have_piece.size())); #endif @@ -3320,7 +3320,7 @@ namespace libtorrent if (t->upload_mode()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** PIECE_PICKER [ not_picking: %d,%d upload_mode ]" , block.piece_index, block.block_index); #endif @@ -3328,7 +3328,7 @@ namespace libtorrent } if (m_disconnecting) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** PIECE_PICKER [ not_picking: %d,%d disconnecting ]" , block.piece_index, block.block_index); #endif @@ -3348,7 +3348,7 @@ namespace libtorrent { if (i->busy) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in download queue & busy ]" , block.piece_index, block.block_index); #endif @@ -3361,7 +3361,7 @@ namespace libtorrent { if (i->busy) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in request queue & busy ]" , block.piece_index, block.block_index); #endif @@ -3373,7 +3373,7 @@ namespace libtorrent if (!t->picker().mark_as_downloading(block, peer_info_struct() , picker_options())) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** PIECE_PICKER [ not_picking: %d,%d failed to mark_as_downloading ]" , block.piece_index, block.block_index); #endif @@ -3412,7 +3412,7 @@ namespace libtorrent TORRENT_ASSERT(t->valid_metadata()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** CANCEL ALL REQUESTS"); #endif @@ -3448,7 +3448,7 @@ namespace libtorrent r.start = block_offset; r.length = block_size; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> CANCEL [ piece: %d s: %d l: %d b: %d ]" , b.piece_index, block_offset, block_size, b.block_index); #endif @@ -3516,7 +3516,7 @@ namespace libtorrent r.start = block_offset; r.length = block_size; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> CANCEL [ piece: %d s: %d l: %d b: %d ]" , block.piece_index, block_offset, block_size, block.block_index); #endif @@ -3541,7 +3541,7 @@ namespace libtorrent m_counters.inc_stats_counter(counters::num_peers_up_unchoked_optimistic, -1); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> CHOKE"); #endif write_choke(); @@ -3566,7 +3566,7 @@ namespace libtorrent } peer_request const& r = *i; m_counters.inc_stats_counter(counters::choked_piece_requests); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> REJECT_PIECE [ piece: %d s: %d l: %d ] choking" , r.piece , r.start , r.length); #endif @@ -3615,7 +3615,7 @@ namespace libtorrent m_uploaded_at_last_unchoke = m_statistics.total_payload_upload(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> UNCHOKE"); #endif return true; @@ -3631,7 +3631,7 @@ namespace libtorrent m_counters.inc_stats_counter(counters::num_peers_down_interested); write_interested(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> INTERESTED"); #endif } @@ -3661,7 +3661,7 @@ namespace libtorrent m_became_uninteresting = aux::time_now(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> NOT_INTERESTED"); #endif } @@ -3712,7 +3712,7 @@ namespace libtorrent if (t->graceful_pause() && m_outstanding_bytes == 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** GRACEFUL PAUSE [ NO MORE DOWNLOAD ]"); #endif disconnect(errors::torrent_paused, op_bittorrent); @@ -3801,7 +3801,7 @@ namespace libtorrent m_download_queue.push_back(block); if (m_queued_time_critical) --m_queued_time_critical; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** MERGING REQUEST [ piece: %d block: %d ]" , block.block.piece_index, block.block.block_index); #endif @@ -3838,7 +3838,7 @@ namespace libtorrent m_last_request = aux::time_now(); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> REQUEST [ piece: %d | s: %x | l: %x | ds: %d B/s | " "dqs: %d rqs: %d blk: %s ]" , r.piece, r.start, r.length, statistics().download_rate() @@ -3855,7 +3855,7 @@ namespace libtorrent // previously did not have a request. That's when we start the // request timeout. m_requested = aux::time_now(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING t->debug_log("REQUEST [%p] (%d ms)", this , int(total_milliseconds(clock_type::now() - m_unchoke_time))); #endif @@ -3867,10 +3867,10 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(e); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("CONNECTION FAILED: %s", print_endpoint(m_remote).c_str()); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_ses.session_log(" CONNECTION FAILED: %s", print_endpoint(m_remote).c_str()); #endif @@ -3940,7 +3940,7 @@ namespace libtorrent m_socket->set_close_reason(error_to_close_reason(ec)); close_reason_t close_reason = (close_reason_t)m_socket->get_close_reason(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (close_reason != 0) { peer_log("*** CLOSE REASON [ %d ]", int(close_reason)); @@ -3952,7 +3952,7 @@ namespace libtorrent // proper books in the piece_picker (when debugging is enabled) torrent_peer* self_peer = peer_info_struct(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING switch (error) { case 0: @@ -4421,7 +4421,7 @@ namespace libtorrent if (exceeded) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** exceeded disk buffer watermark"); #endif if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0) @@ -4441,7 +4441,7 @@ namespace libtorrent m_superseed_piece[0] = -1; m_superseed_piece[1] = -1; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** ending super seed mode"); #endif boost::shared_ptr t = m_torrent.lock(); @@ -4457,7 +4457,7 @@ namespace libtorrent assert(!has_piece(new_piece)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> HAVE [ piece: %d ] (super seed)", new_piece); #endif write_have(new_piece); @@ -4615,7 +4615,7 @@ namespace libtorrent if (d > seconds(connect_timeout) && can_disconnect(error_code(errors::timed_out, get_libtorrent_category()))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** CONNECT FAILED [ waited %d seconds ] ***", int(total_seconds(d))); #endif connect_failed(errors::timed_out); @@ -4635,7 +4635,7 @@ namespace libtorrent if (may_timeout && d > seconds(timeout()) && !m_connecting && m_reading_bytes == 0 && can_disconnect(error_code(errors::timed_out_inactivity, get_libtorrent_category()))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** LAST ACTIVITY [ %d seconds ago ] ***", int(total_seconds(d))); #endif disconnect(errors::timed_out_inactivity, op_bittorrent); @@ -4648,7 +4648,7 @@ namespace libtorrent && in_handshake() && d > seconds(m_settings.get_int(settings_pack::handshake_timeout))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** NO HANDSHAKE [ waited %d seconds ] ***", int(total_seconds(d))); #endif disconnect(errors::timed_out_no_handshake, op_bittorrent); @@ -4669,7 +4669,7 @@ namespace libtorrent && d > seconds(60) && can_disconnect(error_code(errors::timed_out_no_request, get_libtorrent_category()))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** NO REQUEST [ waited %d seconds ] ***", int(total_seconds(d))); #endif disconnect(errors::timed_out_no_request, op_bittorrent); @@ -4698,7 +4698,7 @@ namespace libtorrent || (t && t->num_peers() >= t->max_connections())) && can_disconnect(error_code(errors::timed_out_no_interest))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** MUTUAL NO INTEREST [ t1: %d t2: %d ]" , total_seconds(d1), total_seconds(d2)); #endif @@ -4750,7 +4750,7 @@ namespace libtorrent // requested (this has been observed by BitComet) // in this case we'll clear our download queue and // re-request the blocks. -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** PIECE_REQUEST TIMED OUT [ %d time: %d to: %d ]" , (int)m_download_queue.size(), total_seconds(now - m_last_piece) , piece_timeout); @@ -4945,7 +4945,7 @@ namespace libtorrent if (t->is_deleted()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> REJECT_PIECE [ piece: %d s: %x l: %x ] torrent deleted" , r.piece , r.start , r.length); #endif @@ -4964,7 +4964,7 @@ namespace libtorrent ++m_outstanding_piece_verification; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SEED-MODE FILE ASYNC HASH [ piece: %d ]", r.piece); #endif // this means we're in seed mode and we haven't yet @@ -4988,7 +4988,7 @@ namespace libtorrent // hold off on sending it. If the piece fails later // we will reject this request if (t->is_predictive_piece(r.piece)) continue; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> REJECT_PIECE [ piece: %d s: %x l: %x ] piece not passed hash check" , r.piece , r.start , r.length); #endif @@ -4996,7 +4996,7 @@ namespace libtorrent } else { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** FILE ASYNC READ [ piece: %d | s: %x | l: %x ]" , r.piece, r.start, r.length); #endif @@ -5051,7 +5051,7 @@ namespace libtorrent if (!m_settings.get_bool(settings_pack::disable_hash_checks) && sha1_hash(j->d.piece_hash) != t->torrent_file().hash_for_piece(j->piece)) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SEED-MODE FILE HASH [ piece: %d failed ]", j->piece); #endif @@ -5062,7 +5062,7 @@ namespace libtorrent TORRENT_ASSERT(t->verifying_piece(j->piece)); if (t->seed_mode()) t->verified(j->piece); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SEED-MODE FILE HASH [ piece: %d passed ]", j->piece); #endif if (t) @@ -5087,7 +5087,7 @@ namespace libtorrent int disk_rtt = int(total_microseconds(clock_type::now() - issue_time)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** FILE ASYNC READ COMPLETE [ ret: %d | piece: %d | s: %x | l: %x" " | b: %p | c: %s | e: %s | rtt: %d us ]" , j->ret, r.piece, r.start, r.length, j->buffer @@ -5153,7 +5153,7 @@ namespace libtorrent return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> PIECE [ piece: %d s: %x l: %x ]" , r.piece, r.start, r.length); #endif @@ -5174,7 +5174,7 @@ namespace libtorrent void peer_connection::assign_bandwidth(int channel, int amount) { TORRENT_ASSERT(is_single_thread()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("%s ASSIGN BANDWIDHT [ bytes: %d ]" , channel == upload_channel ? ">>>" : "<<<", amount); #endif @@ -5267,7 +5267,7 @@ namespace libtorrent } #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("%s REQUEST_BANDWIDTH [ bytes: %d quota: %d wanted_transfer: %d " "prio: %d num_channels: %d ]" , channel == download_channel ? "<<<" : ">>>", bytes @@ -5284,7 +5284,7 @@ namespace libtorrent if (ret == 0) m_channel_state[channel] |= peer_info::bw_limit; else { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("%s ASSIGN BANDWIDTH [ bytes: %d ]" , channel == download_channel ? "<<<" : ">>>", ret); #endif @@ -5345,7 +5345,7 @@ namespace libtorrent if ((m_channel_state[upload_channel] & peer_info::bw_disk) == 0) m_counters.inc_stats_counter(counters::num_peers_up_disk); m_channel_state[upload_channel] |= peer_info::bw_disk; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> waiting for disk [outstanding: %d]", m_reading_bytes); #endif @@ -5381,7 +5381,7 @@ namespace libtorrent if (!can_write()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (m_send_buffer.empty()) { peer_log(">>> SEND BUFFER DEPLETED [" @@ -5413,14 +5413,14 @@ namespace libtorrent if (m_corked) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> CORKED WRITE [ bytes: %d ]", amount_to_send); #endif return; } TORRENT_ASSERT((m_channel_state[upload_channel] & peer_info::bw_network) == 0); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> ASYNC_WRITE [ bytes: %d ]", amount_to_send); #endif std::vector const& vec = m_send_buffer.build_iovec(amount_to_send); @@ -5457,7 +5457,7 @@ namespace libtorrent if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0) return; boost::shared_ptr me(self()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** dropped below disk buffer watermark"); #endif m_counters.inc_stats_counter(counters::num_peers_down_disk, -1); @@ -5500,7 +5500,7 @@ namespace libtorrent if (!can_read()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< CANNOT READ [ quota: %d " "can-write-to-disk: %s queue-limit: %d disconnecting: %s " " connecting: %s ]" @@ -5555,7 +5555,7 @@ namespace libtorrent TORRENT_ASSERT((m_channel_state[download_channel] & peer_info::bw_network) == 0); m_channel_state[download_channel] |= peer_info::bw_network; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< ASYNC_READ [ ]"); #endif @@ -5585,7 +5585,7 @@ namespace libtorrent { TORRENT_ASSERT((m_channel_state[download_channel] & peer_info::bw_network) == 0); m_channel_state[download_channel] |= peer_info::bw_network; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< ASYNC_READ [ max: %d bytes ]", max_receive); #endif @@ -5645,7 +5645,7 @@ namespace libtorrent // this is weird. You would imagine read_some() would do this if (ret == 0 && !ec) ec = asio::error::eof; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< SYNC_READ [ max: %d ret: %d e: %s ]", max_receive, ret, ec ? ec.message().c_str() : ""); #endif return ret; @@ -5742,7 +5742,7 @@ namespace libtorrent if (error) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** ERROR [ in peer_connection::on_receive_data_nb error: %s ]" , error.message().c_str()); #endif @@ -5759,7 +5759,7 @@ namespace libtorrent return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< READ_AVAILABLE [ bytes: %d ]", buffer_size); #endif @@ -5866,7 +5866,7 @@ namespace libtorrent , std::size_t bytes_transferred, int read_loops) { TORRENT_ASSERT(is_single_thread()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< ON_RECEIVE_DATA [ bytes: %d error: %s ]" , bytes_transferred, error.message().c_str()); #endif @@ -5889,7 +5889,7 @@ namespace libtorrent if (error) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** ERROR [ in peer_connection::on_receive_data_impl error: %s ]" , error.message().c_str()); #endif @@ -5904,7 +5904,7 @@ namespace libtorrent m_counters.inc_stats_counter(counters::on_read_counter); m_ses.received_buffer(bytes_transferred); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< ON_RECEIVE_DATA [ bytes: %d error: %s ]" , bytes_transferred, error.message().c_str()); #endif @@ -5915,7 +5915,7 @@ namespace libtorrent int num_loops = 0; do { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<<< read %d bytes", int(bytes_transferred)); #endif // correct the dl quota usage, if not all of the buffer was actually read @@ -6045,7 +6045,7 @@ namespace libtorrent m_counters.inc_stats_counter(counters::num_peers_down_disk); const_cast(this)->m_channel_state[download_channel] |= peer_info::bw_disk; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** exceeded disk buffer watermark"); #endif return false; @@ -6064,13 +6064,13 @@ namespace libtorrent complete_async("peer_connection::on_connection_complete"); #endif -#if defined TORRENT_LOGGING || defined TORRENT_USE_OPENSSL +#if !defined TORRENT_DISABLE_LOGGING || defined TORRENT_USE_OPENSSL time_point completed = clock_type::now(); #endif INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING { boost::shared_ptr t = m_torrent.lock(); t->debug_log("END connect [%p]", this); @@ -6149,14 +6149,14 @@ namespace libtorrent received_synack(m_remote.address().is_v6()); TORRENT_ASSERT(m_socket); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> COMPLETED [ ep: %s ]", print_endpoint(m_remote).c_str()); #endif // set the socket to non-blocking, so that we can // read the entire buffer on each read event we get tcp::socket::non_blocking_io ioc(true); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SET NON-BLOCKING"); #endif m_socket->io_control(ioc, ec); @@ -6179,7 +6179,7 @@ namespace libtorrent { error_code ec; m_socket->set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_settings.get_int(settings_pack::peer_tos), ec.message().c_str()); #endif } @@ -6223,7 +6223,7 @@ namespace libtorrent // in the current message queue m_ses.deferred_submit_jobs(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** ON_SEND_DATA [ bytes: %d error: %s ]" , int(bytes_transferred), error.message().c_str()); #endif @@ -6265,13 +6265,13 @@ namespace libtorrent if (m_send_barrier != INT_MAX) m_send_barrier -= bytes_transferred; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log(">>> wrote %d bytes", int(bytes_transferred)); #endif if (error) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("**ERROR**: %s [in peer_connection::on_send_data]", error.message().c_str()); #endif disconnect(error, op_sock_write); @@ -6588,7 +6588,7 @@ namespace libtorrent // alive if (m_channel_state[upload_channel] & peer_info::bw_network) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> KEEPALIVE"); #endif diff --git a/src/peer_list.cpp b/src/peer_list.cpp index 7e8bff9d7..a295ce299 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -65,7 +65,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" // for print_endpoint #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" // for print_endpoint #include "libtorrent/ip_voter.hpp" // for external_ip #endif @@ -620,7 +620,7 @@ namespace libtorrent TORRENT_ASSERT(i->connection != &c); TORRENT_ASSERT(i->address() == c.remote().address()); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING c.peer_log("*** DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]" , print_address(c.remote().address()).c_str() , print_address(i->address()).c_str()); @@ -678,7 +678,7 @@ namespace libtorrent if (our_port < other_port) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING 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); #endif @@ -696,7 +696,7 @@ namespace libtorrent } else { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING 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); #endif diff --git a/src/request_blocks.cpp b/src/request_blocks.cpp index c02f76628..995c97bb3 100644 --- a/src/request_blocks.cpp +++ b/src/request_blocks.cpp @@ -90,7 +90,7 @@ namespace libtorrent - (int)c.download_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 ]" , int(c.download_queue().size()), int(c.request_queue().size()) , c.desired_queue_size(), num_requests, c.endgame()); @@ -162,7 +162,7 @@ namespace libtorrent , c.picker_options(), suggested, t.num_peers() , ses.stats_counters()); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING c.peer_log("*** PIECE_PICKER [ prefer_contiguous: %d picked: %d ]" , prefer_contiguous_blocks, int(interesting_pieces.size())); #endif @@ -227,7 +227,7 @@ namespace libtorrent = std::find_if(dq.begin(), dq.end(), has_block(*i)); if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted); #endif -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING c.peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in queue ]" , i->piece_index, i->block_index); #endif diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 047c5c8f3..ef8e8a81c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -99,7 +99,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" @@ -118,7 +118,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/http_tracker_connection.hpp" #include "libtorrent/udp_tracker_connection.hpp" -#endif // TORRENT_LOGGING +#endif // TORRENT_DISABLE_LOGGING #ifdef TORRENT_USE_GCRYPT @@ -361,7 +361,7 @@ namespace aux { #endif , m_tracker_manager(m_udp_socket, m_stats_counters, m_host_resolver , m_ip_filter, m_settings -#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS +#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS , *this #endif ) @@ -461,7 +461,7 @@ namespace aux { { m_alerts.set_alert_mask(pack.get_int(settings_pack::alert_mask)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("start session"); #endif @@ -518,7 +518,7 @@ namespace aux { // 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. -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("config: %s\n" "version: %s\n" @@ -527,7 +527,7 @@ namespace aux { , LIBTORRENT_VERSION , LIBTORRENT_REVISION); -#endif // TORRENT_LOGGING +#endif // TORRENT_DISABLE_LOGGING #if TORRENT_USE_RLIMIT // ---- auto-cap max connections ---- @@ -535,7 +535,7 @@ namespace aux { struct rlimit rl; 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); #endif // deduct some margin for epoll/kqueue, log files, @@ -547,7 +547,7 @@ namespace aux { m_settings.get_int(settings_pack::connections_limit) , int(rl.rlim_cur * 8 / 10))); // 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 files: %d", int(rl.rlim_cur * 2 / 10)); #endif @@ -555,7 +555,7 @@ namespace aux { #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()); #endif @@ -564,7 +564,7 @@ namespace aux { // call update_* after settings set initialized m_io_service.post(boost::bind(&session_impl::init_settings, this)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" spawning network thread"); #endif m_thread.reset(new thread(boost::bind(&session_impl::main_thread, this))); @@ -655,7 +655,7 @@ namespace aux { void session_impl::init() { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" *** session thread init"); #endif @@ -684,7 +684,7 @@ namespace aux { update_dht_announce_interval(); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" done starting session"); #endif } @@ -950,7 +950,7 @@ namespace aux { TORRENT_ASSERT(is_single_thread()); if (m_paused) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" *** session paused ***"); #endif m_paused = true; @@ -982,7 +982,7 @@ namespace aux { TORRENT_ASSERT(is_single_thread()); if (m_abort) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" *** ABORT CALLED ***"); #endif @@ -1038,7 +1038,7 @@ namespace aux { m_i2p_listen_socket.reset(); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" aborting all torrents (%d)", m_torrents.size()); #endif // abort all torrents @@ -1049,12 +1049,12 @@ namespace aux { } m_torrents.clear(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" aborting all tracker requests"); #endif m_tracker_manager.abort_all_requests(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" aborting all connections (%d)", m_connections.size()); #endif // abort all connections @@ -1580,7 +1580,7 @@ namespace aux { if (m_alerts.should_post()) m_alerts.emplace_alert(device, last_op, ec, sock_type); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("failed to open socket: %s: %s" , device.c_str(), ec.message().c_str()); #endif @@ -1622,7 +1622,7 @@ namespace aux { while (ec && retries > 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("failed to bind to interface [%s] \"%s\": %s" , device.c_str(), bind_ip.to_string(ec).c_str() , ec.message().c_str()); @@ -1650,7 +1650,7 @@ namespace aux { // not even that worked, give up if (m_alerts.should_post()) m_alerts.emplace_alert(device, last_op, ec, sock_type); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("cannot bind to interface \"%s\": %s" , device.c_str(), ec.message().c_str()); #endif @@ -1668,7 +1668,7 @@ namespace aux { { if (m_alerts.should_post()) m_alerts.emplace_alert(device, last_op, ec, sock_type); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("cannot listen on interface \"%s\": %s" , device.c_str(), ec.message().c_str()); #endif @@ -1685,7 +1685,7 @@ namespace aux { { if (m_alerts.should_post()) m_alerts.emplace_alert(device, last_op, ec, sock_type); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("failed to get peer name \"%s\": %s" , device.c_str(), ec.message().c_str()); #endif @@ -1698,7 +1698,7 @@ namespace aux { , (flags & open_ssl_socket) ? listen_succeeded_alert::tcp_ssl : listen_succeeded_alert::tcp); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" listening on: %s external port: %d" , print_endpoint(tcp::endpoint(bind_ip, port)).c_str(), ret.external_port); #endif @@ -1707,7 +1707,7 @@ namespace aux { void session_impl::open_listen_port() { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("open listen port"); #endif @@ -1900,7 +1900,7 @@ retry: 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" , print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); #endif @@ -1928,7 +1928,7 @@ retry: m_ssl_udp_socket.bind(ssl_bind_if, ec); if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("SSL: cannot bind to UDP interface \"%s\": %s" , print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); #endif @@ -1954,7 +1954,7 @@ retry: m_udp_socket.bind(udp::endpoint(m_listen_interface.address(), m_listen_interface.port()), ec); if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("cannot bind to UDP interface \"%s\": %s" , print_endpoint(m_listen_interface).c_str(), ec.message().c_str()); #endif @@ -2101,7 +2101,7 @@ retry: if (m_alerts.should_post()) m_alerts.emplace_alert(ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("i2p open failed (%d) %s", ec.value(), ec.message().c_str()); #endif } @@ -2146,7 +2146,7 @@ retry: if (m_alerts.should_post()) m_alerts.emplace_alert("i2p", listen_failed_alert::accept , e, listen_failed_alert::i2p); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("cannot bind to port %d: %s" , m_listen_interface.port(), e.message().c_str()); #endif @@ -2169,7 +2169,7 @@ retry: && m_alerts.should_post()) m_alerts.emplace_alert(ep, ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("UDP socket error: (%d) %s", ec.value(), ec.message().c_str()); #endif } @@ -2231,7 +2231,7 @@ retry: if (e) { tcp::endpoint ep = listener->local_endpoint(ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("error accepting connection on '%s': %s" , print_endpoint(ep).c_str(), e.message().c_str()); #endif @@ -2346,7 +2346,7 @@ retry: tcp::endpoint endp = s->remote_endpoint(e); if (e) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" *** peer SSL handshake done [ ip: %s ec: %s socket: %s ]" , print_endpoint(endp).c_str(), ec.message().c_str(), s->type_name()); #endif @@ -2379,7 +2379,7 @@ retry: if (m_paused) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" <== INCOMING CONNECTION [ ignored, paused ]"); #endif return; @@ -2391,7 +2391,7 @@ retry: if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("%s <== INCOMING CONNECTION FAILED, could " "not retrieve remote endpoint " , print_endpoint(endp).c_str(), ec.message().c_str()); @@ -2399,7 +2399,7 @@ retry: return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" <== INCOMING CONNECTION %s type: %s" , print_endpoint(endp).c_str(), s->type_name()); #endif @@ -2407,7 +2407,7 @@ retry: if (!m_settings.get_bool(settings_pack::enable_incoming_utp) && is_utp(*s)) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" rejected uTP connection"); #endif if (m_alerts.should_post()) @@ -2419,7 +2419,7 @@ retry: if (!m_settings.get_bool(settings_pack::enable_incoming_tcp) && s->get()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" rejected TCP connection"); #endif if (m_alerts.should_post()) @@ -2436,7 +2436,7 @@ retry: tcp::endpoint local = s->local_endpoint(ec); if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" rejected connection: (%d) %s", ec.value() , ec.message().c_str()); #endif @@ -2447,14 +2447,14 @@ retry: { if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" rejected connection, not allowed local interface: (%d) %s" , ec.value(), ec.message().c_str()); #endif return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" rejected connection, not allowed local interface: %s" , local.address().to_string(ec).c_str()); #endif @@ -2478,7 +2478,7 @@ retry: if (m_stats_counters[counters::non_filter_torrents] == 0 && (m_ip_filter.access(endp.address()) & ip_filter::blocked)) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("filtered blocked ip"); #endif if (m_alerts.should_post()) @@ -2491,7 +2491,7 @@ retry: // if we don't reject the connection if (m_torrents.empty()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" There are no torrents, disconnect"); #endif return; @@ -2527,7 +2527,7 @@ retry: , error_code(errors::too_many_connections, get_libtorrent_category()) , 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" , num_connections(), m_settings.get_int(settings_pack::connections_limit) , m_settings.get_int(settings_pack::connections_slack)); @@ -2554,7 +2554,7 @@ retry: } if (!has_active_torrent) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" There are no _active_ torrents, disconnect"); #endif return; @@ -2651,7 +2651,7 @@ retry: // TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p)); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" CLOSING CONNECTION %s : %s" , print_endpoint(p->remote()).c_str(), ec.message().c_str()); #endif @@ -2686,7 +2686,7 @@ retry: int port = m_next_port; ++m_next_port; 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); #endif return port; @@ -2833,7 +2833,7 @@ retry: if (e) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("*** TICK TIMER FAILED %s", e.message().c_str()); #endif ::abort(); @@ -3301,7 +3301,7 @@ retry: TORRENT_ASSERT(m_dht); m_dht_torrents.push_back(t); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr tor = t.lock(); if (tor) session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str()); @@ -3330,7 +3330,7 @@ retry: TORRENT_ASSERT(is_single_thread()); if (e) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("aborting DHT announce timer (%d): %s" , e.value(), e.message().c_str()); #endif @@ -3339,7 +3339,7 @@ retry: if (m_abort) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("aborting DHT announce timer: m_abort set"); #endif return; @@ -3473,7 +3473,7 @@ retry: { --hard_limit; --type_limit; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (!t->allows_peers()) t->log_to_all_peers("AUTO MANAGER STARTING TORRENT"); #endif @@ -3481,7 +3481,7 @@ retry: } else { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (t->allows_peers()) t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT"); #endif @@ -4040,7 +4040,7 @@ retry: stop_loop = m_abort; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" locking mutex"); #endif @@ -4053,7 +4053,7 @@ retry: } #endif */ -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" cleaning up torrents"); #endif @@ -4276,7 +4276,7 @@ retry: return i->second; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING void session_impl::session_log(char const* fmt, ...) const { if (!m_alerts.should_post()) return; @@ -4555,7 +4555,7 @@ retry: error_code ec; bdecode_node tmp; bdecode_node info; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("adding magnet link with resume data"); #endif if (bdecode(¶ms.resume_data[0], ¶ms.resume_data[0] @@ -4563,7 +4563,7 @@ retry: && tmp.type() == bdecode_node::dict_t && (info = tmp.dict_find_dict("info"))) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("found metadata in resume data"); #endif // verify the info-hash of the metadata stored in the resume file matches @@ -4579,14 +4579,14 @@ retry: || !params.url.empty() || params.info_hash.is_all_zeros()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("info-hash matched"); #endif params.ti = boost::make_shared(resume_ih); 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"); #endif // make the info-hash be the one in the resume file @@ -4595,20 +4595,20 @@ retry: } else { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("failed to load metadata from resume file: %s" , ec.message().c_str()); #endif } } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING else { session_log("metadata info-hash failed"); } #endif } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING else { session_log("no metadata found"); @@ -4936,7 +4936,7 @@ retry: // declared in string_util.hpp 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()); #endif @@ -4964,14 +4964,14 @@ retry: device_name[0] == '[' ? device_name + 1 : device_name, ec)); if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("failed to treat %s as an IP address [ %s ]" , device_name, ec.message().c_str()); #endif // it may have been a device name. std::vector ifs = enum_net_interfaces(m_io_service, ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (ec) session_log("failed to enumerate interfaces [ %s ]" , ec.message().c_str()); @@ -4985,7 +4985,7 @@ retry: // connecting to) if (strcmp(ifs[i].name, device_name) != 0) continue; m_listen_interface.address(ifs[i].interface_address); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("binding to %s" , m_listen_interface.address().to_string(ec).c_str()); #endif @@ -4995,7 +4995,7 @@ retry: if (!found) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("failed to find device %s", device_name); #endif // effectively disable whatever socket decides to bind to this @@ -5180,7 +5180,7 @@ retry: if (t->torrent_file().priv() || (t->torrent_file().is_i2p() && !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()); #endif 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); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(">>> SET_TOS [ udp_socket tos: %x e: %s ]" , m_settings.get_int(settings_pack::peer_tos) , ec.message().c_str()); @@ -5967,7 +5967,7 @@ retry: #ifndef TORRENT_DISABLE_DHT if (!m_dht) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("not starting DHT announce timer: m_dht == NULL"); #endif return; @@ -5978,7 +5978,7 @@ retry: // if we haven't started yet, don't actually trigger this if (!m_thread) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("not starting DHT announce timer: thread not running yet"); #endif return; @@ -5986,7 +5986,7 @@ retry: if (m_abort) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log("not starting DHT announce timer: m_abort set"); #endif return; @@ -6276,7 +6276,7 @@ retry: m_lsd = boost::make_shared(boost::ref(m_io_service) , 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) #endif ); @@ -6286,7 +6286,7 @@ retry: m_alerts.emplace_alert(ec); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING void session_impl::on_lsd_log(char const* log) { if (!m_alerts.should_post()) return; @@ -6456,14 +6456,14 @@ retry: void session_impl::set_external_address(address const& ip , 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() , source_type, print_address(source).c_str()); #endif if (!m_external_ip.cast_vote(ip, source_type, source)) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING session_log(" external IP updated"); #endif @@ -6734,7 +6734,7 @@ retry: } #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING tracker_logger::tracker_logger(session_interface& ses): m_ses(ses) {} void tracker_logger::tracker_warning(tracker_request const& req , std::string const& str) @@ -6747,7 +6747,7 @@ retry: , std::list
const& ip_list , struct tracker_response const& resp) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("TRACKER RESPONSE\n" "interval: %d\n" "external ip: %s\n" diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 79ff43e81..7edf78d8a 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -62,7 +62,7 @@ POSSIBILITY OF SUCH DAMAGE. //#define TORRENT_LOG_HASH_FAILURES -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" #endif @@ -139,7 +139,7 @@ namespace 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 ]" , p, int(m_block_hashes.size())); #endif @@ -275,7 +275,7 @@ namespace // this time the digest of the block is different // from the first time it sent it // at least one of them must be bad -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char const* client = "-"; peer_info info; if (p->connection) @@ -301,7 +301,7 @@ namespace m_block_hashes.insert(i, std::pair(b, e)); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char const* client = "-"; peer_info info; if (p->connection) @@ -350,7 +350,7 @@ namespace } if (p == NULL) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char const* client = "-"; peer_info info; if (p->connection) diff --git a/src/torrent.cpp b/src/torrent.cpp index 480e9397c..f01b3a285 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -97,7 +97,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif // BOOST_VERSION #endif // TORRENT_USE_OPENSSL -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/aux_/session_impl.hpp" // for tracker_logger #endif @@ -719,12 +719,12 @@ namespace libtorrent // TODO: 2 post alert -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** FAILED SEED MODE, rechecking"); #endif } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** LEAVING SEED MODE (%s)", seed ? "as seed" : "as non-seed"); #endif m_seed_mode = false; @@ -755,7 +755,7 @@ namespace libtorrent void torrent::start() { TORRENT_ASSERT(is_single_thread()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("starting torrent"); #endif std::vector().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.reset(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("resume data rejected: %s pos: %d", ec.message().c_str(), pos); #endif if (m_ses.alerts().should_post()) @@ -1071,7 +1071,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); 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() , resolve_filename(j->error.file).c_str()); #endif @@ -1474,7 +1474,7 @@ namespace libtorrent GENERAL_NAMES* gens = static_cast( X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::string names; bool match = false; #endif @@ -1487,14 +1487,14 @@ namespace libtorrent const char* torrent_name = reinterpret_cast(domain->data); std::size_t name_length = domain->length; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (i > 1) names += " | n: "; names.append(torrent_name, name_length); #endif if (strncmp(torrent_name, "*", 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; // if we're logging, keep looping over all names, // for completeness of the log @@ -1519,7 +1519,7 @@ namespace libtorrent const char* torrent_name = reinterpret_cast(common_name->data); std::size_t name_length = common_name->length; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (!names.empty()) names += " | n: "; names.append(torrent_name, name_length); #endif @@ -1527,7 +1527,7 @@ namespace libtorrent if (strncmp(torrent_name, "*", 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; #else 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 ]" , names.c_str(), match?"yes":"no"); return match; @@ -1709,7 +1709,7 @@ namespace libtorrent { TORRENT_ASSERT(is_single_thread()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("init torrent: %s", torrent_file().name().c_str()); #endif @@ -1770,7 +1770,7 @@ namespace libtorrent if (ev) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("fastresume data rejected: %s" , error_code(ev, get_libtorrent_category()).message().c_str()); #endif @@ -1989,7 +1989,7 @@ namespace libtorrent m_storage.get(), m_resume_data ? &m_resume_data->node : NULL , links, boost::bind(&torrent::on_resume_data_checked , shared_from_this(), _1)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("init, async_check_fastresume"); #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) debug_log("resume added peers (%d)", m_peer_list->num_peers()); #endif @@ -2318,13 +2318,13 @@ namespace libtorrent , resolve_filename(j->error.file), j->error.operation_str()); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (j->ret != 0) { debug_log("fastresume data rejected: ret: %d (%d) %s" , j->ret, j->error.ec.value(), j->error.ec.message().c_str()); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING else debug_log("fastresume data accepted"); #endif @@ -2548,7 +2548,7 @@ namespace libtorrent // resumed quickly, before the outstanding jobs completed 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" , m_checking_piece, m_torrent_file->num_pieces()); #endif @@ -2561,7 +2561,7 @@ namespace libtorrent if (!need_loaded()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("start_checking, need_loaded() failed"); #endif return; @@ -2576,7 +2576,7 @@ namespace libtorrent , shared_from_this(), _1), (void*)1); 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); #endif } @@ -2599,7 +2599,7 @@ namespace libtorrent { m_checking_piece = 0; m_num_checked_pieces = 0; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("on_piece_hashed, disk_check_aborted"); #endif pause(); @@ -2640,7 +2640,7 @@ namespace libtorrent m_ses.alerts().emplace_alert(j->error.ec, 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()); #endif auto_managed(false); @@ -2659,7 +2659,7 @@ namespace libtorrent // we're using the piece hashes here, we need the torrent to be loaded if (!need_loaded()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("on_piece_hashed, need_loaded failed"); #endif return; @@ -2705,7 +2705,7 @@ namespace libtorrent // we paused the checking if (!should_check_files()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("on_piece_hashed, checking paused"); #endif return; @@ -2713,7 +2713,7 @@ namespace libtorrent if (!need_loaded()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("on_piece_hashed, need_loaded failed"); #endif return; @@ -2724,13 +2724,13 @@ namespace libtorrent , disk_io_job::sequential_access | disk_io_job::volatile_read , boost::bind(&torrent::on_piece_hashed , 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); #endif return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("on_piece_hashed, completed"); #endif // we're done checking! @@ -2820,14 +2820,14 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); if (!m_ses.dht()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("DHT: no dht initialized"); #endif return; } if (!should_announce_dht()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (!m_ses.announce_dht()) debug_log("DHT: no listen sockets"); @@ -2868,7 +2868,7 @@ namespace libtorrent int port = m_ses.listen_port(); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("START DHT announce"); m_dht_start_time = clock_type::now(); #endif @@ -2900,7 +2900,7 @@ namespace libtorrent { TORRENT_ASSERT(is_single_thread()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("END DHT announce (%d ms) (%d peers)" , int(total_milliseconds(clock_type::now() - m_dht_start_time)) , int(peers.size())); @@ -2935,7 +2935,7 @@ namespace libtorrent if (m_trackers.empty()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** announce: no trackers"); #endif return; @@ -2947,7 +2947,7 @@ namespace libtorrent // stopping 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"); #endif return; @@ -2956,7 +2956,7 @@ namespace libtorrent // if we're not allowing peers, there's no point in announcing if (e != tracker_request::stopped && !m_allow_peers) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** announce: event != stopped && !m_allow_peers"); #endif return; @@ -3008,7 +3008,7 @@ namespace libtorrent for (int i = 0; i < int(m_trackers.size()); ++i) { announce_entry& ae = m_trackers[i]; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** tracker: \"%s\" " "[ tiers: %d trackers: %d" " i->tier: %d tier: %d" @@ -3091,7 +3091,7 @@ namespace libtorrent req.auth = tracker_login(); req.key = tracker_key(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d" , req.url.c_str() , (req.event==tracker_request::stopped?"stopped" @@ -3269,7 +3269,7 @@ namespace libtorrent if (resp.complete >= 0 && resp.incomplete >= 0) m_last_scrape = m_ses.session_time(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("TRACKER RESPONSE\n" "interval: %d\n" "external ip: %s\n" @@ -3409,7 +3409,7 @@ namespace libtorrent ?m_ses.get_ipv6_interface().address() :m_ses.get_ipv4_interface().address(); 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" , print_address(bind_interface).c_str()); #endif @@ -3475,7 +3475,7 @@ namespace libtorrent continue; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING external_ip const& external = m_ses.external_address(); debug_log(" *** FOUND CONNECTION CANDIDATE [" " ip: %s rank: %u external: %s t: %d ]" @@ -3543,7 +3543,7 @@ namespace libtorrent INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (ec) debug_log("i2p_resolve error: %s", ec.message().c_str()); #endif @@ -3568,7 +3568,7 @@ namespace libtorrent complete_async("torrent::on_peer_name_lookup"); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (e) debug_log("peer name lookup error: %s", e.message().c_str()); #endif @@ -3581,7 +3581,7 @@ namespace libtorrent if (m_apply_ip_filter && m_ses.get_ip_filter().access(host.address()) & ip_filter::blocked) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING error_code ec; debug_log("blocked ip from tracker: %s", host.address().to_string(ec).c_str()); #endif @@ -3945,7 +3945,7 @@ namespace libtorrent // -1: disk failure // -2: piece failed check -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** PIECE_FINISHED [ p: %d | chk: %s | size: %d ]" , j->piece, ((ret == 0) ?"passed":ret == -1 @@ -4185,7 +4185,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(!m_picker->has_piece_passed(index)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("PIECE_PASSED (%d)", num_passed()); #endif @@ -4260,7 +4260,7 @@ namespace libtorrent for (peer_iterator p = m_connections.begin() , 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]" , index, milliseconds); #endif @@ -4402,11 +4402,11 @@ namespace libtorrent if (p->connection) { peer_connection* peer = static_cast(p->connection); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** BANNING PEER: \"%s\" Too many corrupt pieces" , print_endpoint(p->ip()).c_str()); #endif -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer->peer_log("*** BANNING PEER: Too many corrupt pieces"); #endif peer->disconnect(errors::too_many_corrupt_pieces, op_bittorrent); @@ -4764,7 +4764,7 @@ namespace libtorrent error_code ec; m_inactivity_timer.cancel(ec); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_to_all_peers("ABORTING TORRENT"); #endif @@ -5513,7 +5513,7 @@ namespace libtorrent p->update_interest(); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** UPDATE_PEER_INTEREST [ finished: %d was_finished %d ]" , is_finished(), was_finished); #endif @@ -5997,7 +5997,7 @@ namespace libtorrent if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("failed to parse web seed url: %s", ec.message().c_str()); #endif if (m_ses.alerts().should_post()) @@ -6012,7 +6012,7 @@ namespace libtorrent if (web->peer_info.banned) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("banned web seed: %s", web->url.c_str()); #endif if (m_ses.alerts().should_post()) @@ -6082,7 +6082,7 @@ namespace libtorrent return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("resolving web seed: %s", web->url.c_str()); #endif @@ -6090,7 +6090,7 @@ namespace libtorrent if (ps.type == settings_pack::http || 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()); #endif @@ -6108,7 +6108,7 @@ namespace libtorrent } else { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("resolving web seed: %s", web->url.c_str()); #endif @@ -6128,7 +6128,7 @@ namespace libtorrent INVARIANT_CHECK; 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()); if (e) debug_log("proxy name lookup error: %s", e.message().c_str()); @@ -6137,7 +6137,7 @@ namespace libtorrent if (web->removed) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("removed web seed"); #endif remove_web_seed(web); @@ -6213,13 +6213,13 @@ namespace libtorrent INVARIANT_CHECK; TORRENT_ASSERT(web->resolving == true); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("completed resolve: %s", web->url.c_str()); #endif web->resolving = false; if (web->removed) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("removed web seed"); #endif remove_web_seed(web); @@ -6232,7 +6232,7 @@ namespace libtorrent { if (m_ses.alerts().should_post()) m_ses.alerts().emplace_alert(get_handle(), web->url, e); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** HOSTNAME LOOKUP FAILED: %s: (%d) %s" , web->url.c_str(), e.value(), e.message().c_str()); #endif @@ -6248,7 +6248,7 @@ namespace libtorrent // fill in the peer struct's address field 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()); #endif } @@ -6414,7 +6414,7 @@ namespace libtorrent , boost::int64_t(web->peer_info.prev_amount_upload) << 10); web->peer_info.prev_amount_download = 0; web->peer_info.prev_amount_upload = 0; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("web seed connection started: [%s] %s" , print_endpoint(a).c_str(), web->url.c_str()); #endif @@ -6423,7 +6423,7 @@ namespace libtorrent if (c->is_disconnecting()) return; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("START queue peer [%p] (%d)", c.get(), num_peers()); #endif } @@ -6431,7 +6431,7 @@ namespace libtorrent { TORRENT_DECLARE_DUMMY(std::exception, e); (void)e; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** PEER_ERROR: %s", e.what()); #endif c->disconnect(errors::no_error, op_bittorrent, 1); @@ -6584,7 +6584,7 @@ namespace libtorrent { // unknown country! p->set_country("!!"); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("IP \"%s\" was mapped to unknown country: %d" , print_address(p->remote().address()).c_str(), country); #endif @@ -7730,7 +7730,7 @@ namespace libtorrent if (!m_peer_list->new_connection(*p, m_ses.session_time(), &st)) { peers_erased(st.erased); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("CLOSING CONNECTION \"%s\" peer list full" , print_endpoint(p->remote()).c_str()); #endif @@ -7744,7 +7744,7 @@ namespace libtorrent { TORRENT_DECLARE_DUMMY(std::exception, e); (void)e; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("CLOSING CONNECTION \"%s\" caught exception: %s" , print_endpoint(p->remote()).c_str(), e.what()); #endif @@ -7762,7 +7762,7 @@ namespace libtorrent ++m_num_seeds; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("incoming peer (%d)", int(m_connections.size())); #endif @@ -8038,7 +8038,7 @@ namespace libtorrent TORRENT_ASSERT(p->associated_torrent().lock().get() == this); if (p->upload_only()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING p->peer_log("*** SEED, CLOSING CONNECTION"); #endif seeds.push_back(p); @@ -8079,7 +8079,7 @@ namespace libtorrent || m_state == torrent_status::checking_files || m_state == torrent_status::allocating) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** RESUME_DOWNLOAD [ skipping, state: %d ]" , int(m_state)); #endif @@ -8092,7 +8092,7 @@ namespace libtorrent m_completed_time = 0; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** RESUME_DOWNLOAD"); #endif send_upload_only(); @@ -8188,7 +8188,7 @@ namespace libtorrent if (m_abort) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("files_checked(), paused"); #endif return; @@ -8279,7 +8279,7 @@ namespace libtorrent pc->init(); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING pc->peer_log("*** ON_FILES_CHECKED"); #endif if (pc->is_interesting() && !pc->has_peer_choked()) @@ -8765,7 +8765,7 @@ namespace libtorrent { TORRENT_ASSERT(is_single_thread()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_to_all_peers("DELETING FILES IN TORRENT"); #endif @@ -8838,7 +8838,7 @@ namespace libtorrent alerts().emplace_alert(get_handle(), ec , resolve_filename(error_file)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (ec) { char buf[1024]; @@ -9179,7 +9179,7 @@ namespace libtorrent update_want_peers(); update_want_scrape(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING log_to_all_peers("PAUSING TORRENT"); #endif @@ -9236,7 +9236,7 @@ namespace libtorrent if (p->outstanding_bytes() > 0) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING p->peer_log("*** CHOKING PEER: torrent graceful paused"); #endif // remove any un-sent requests from the queue @@ -9246,7 +9246,7 @@ namespace libtorrent continue; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING p->peer_log("*** CLOSING CONNECTION: torrent_paused"); #endif 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) { TORRENT_ASSERT(is_single_thread()); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING for (peer_iterator i = m_connections.begin(); i != m_connections.end(); ++i) { @@ -9397,7 +9397,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); if (!m_announcing) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** update tracker timer: not announcing"); #endif return; @@ -9411,7 +9411,7 @@ namespace libtorrent for (std::vector::iterator i = m_trackers.begin() , end(m_trackers.end()); i != end; ++i) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char msg[1000]; snprintf(msg, sizeof(msg), "*** tracker: \"%s\" " "[ tiers: %d trackers: %d" @@ -9449,7 +9449,7 @@ namespace libtorrent && !settings().get_bool(settings_pack::announce_to_all_tiers)) break; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char msg[200]; snprintf(msg, sizeof(msg), "*** update tracker timer: next_announce < now %d" " m_waiting_tracker: %d next_announce_in: %d" @@ -9479,7 +9479,7 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); if (is_paused()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("start_announcing(), paused"); #endif return; @@ -9489,14 +9489,14 @@ namespace libtorrent // request the metadata from if (!m_files_checked && valid_metadata()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("start_announcing(), files not checked (with valid metadata)"); #endif return; } if (!m_torrent_file->is_valid() && !m_url.empty()) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("start_announcing(), downloading URL"); #endif return; @@ -9728,7 +9728,7 @@ namespace libtorrent { TORRENT_DECLARE_DUMMY(std::exception, e); (void)e; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING p->peer_log("*** ERROR %s", e.what()); #endif p->disconnect(errors::no_error, op_bittorrent, 1); @@ -10663,7 +10663,7 @@ namespace libtorrent TORRENT_ASSERT(i->resolving == false); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("disconnect web seed: \"%s\"", i->url.c_str()); #endif TORRENT_ASSERT(i->peer_info.connection); @@ -11237,7 +11237,7 @@ namespace libtorrent m_state = s; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("set_state() %d", m_state); #endif @@ -11576,7 +11576,7 @@ namespace libtorrent INVARIANT_CHECK; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** tracker error: (%d) %s %s", ec.value() , ec.message().c_str(), msg.c_str()); #endif @@ -11589,7 +11589,7 @@ namespace libtorrent ae->last_error = ec; ae->message = msg; int tracker_index = ae - &m_trackers[0]; -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING debug_log("*** increment tracker fail count [%d]", ae->fails); #endif // never talk to this tracker again @@ -11623,7 +11623,7 @@ namespace libtorrent update_tracker_timer(aux::time_now()); } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING void torrent::debug_log(char const* fmt, ...) const { if (!alerts().should_post()) return; diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index 942cf443c..1e5a7aff2 100644 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -200,7 +200,7 @@ namespace libtorrent , resolver_interface& resolver , struct ip_filter& ipf , aux::session_settings const& sett -#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS +#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS , aux::session_logger& ses #endif ) @@ -209,7 +209,7 @@ namespace libtorrent , m_host_resolver(resolver) , m_settings(sett) , m_stats_counters(stats_counters) -#if defined TORRENT_LOGGING || TORRENT_USE_ASSERTS +#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS , m_ses(ses) #endif , m_abort(false) @@ -319,7 +319,7 @@ namespace libtorrent // ignore packets smaller than 8 bytes if (size < 8) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_ses.session_log("incoming packet from %s, not a UDP tracker message " "(%d Bytes)", print_endpoint(ep).c_str(), size); #endif @@ -332,7 +332,7 @@ namespace libtorrent 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 " "transaction ID (%" PRIu32 ")", print_endpoint(ep).c_str() , transaction); @@ -362,7 +362,7 @@ namespace libtorrent 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, // but chances are pretty good, so it's probably worth logging m_ses.session_log("incoming UDP tracker packet from %s has invalid " @@ -395,7 +395,7 @@ namespace libtorrent close_http_connections.push_back(*i); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr rc = c->requester(); if (rc) rc->debug_log("aborting: %s", req.url.c_str()); #endif @@ -410,7 +410,7 @@ namespace libtorrent close_udp_connections.push_back(c); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr rc = c->requester(); if (rc) rc->debug_log("aborting: %s", req.url.c_str()); #endif diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index 5341caf69..b078c211f 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/ip_filter.hpp" #include "libtorrent/aux_/time.hpp" -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" #endif @@ -126,7 +126,7 @@ namespace libtorrent , boost::bind(&udp_tracker_connection::name_lookup , shared_from_this(), _1, _2, port)); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]" , hostname.c_str()); @@ -155,7 +155,7 @@ namespace libtorrent return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); 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()); @@ -164,7 +164,7 @@ namespace libtorrent // pick another target endpoint and try again 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\" ]" , m_hostname.c_str(), print_endpoint(m_target).c_str()); #endif @@ -193,7 +193,7 @@ namespace libtorrent } boost::shared_ptr cb = requester(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]"); #endif if (cancelled()) @@ -220,7 +220,7 @@ namespace libtorrent { 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 ]" , print_address(k->address()).c_str()); #endif @@ -314,7 +314,7 @@ namespace libtorrent return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str()); #endif @@ -340,14 +340,14 @@ namespace libtorrent bool udp_tracker_connection::on_receive(error_code const& e , udp::endpoint const& ep, char const* buf, int size) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); #endif // ignore resposes before we've sent any requests if (m_state == action_error) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("<== UDP_TRACKER [ m_action == error ]"); #endif return false; @@ -355,7 +355,7 @@ namespace libtorrent if (m_abort) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("<== UDP_TRACKER [ aborted]"); #endif return false; @@ -367,7 +367,7 @@ namespace libtorrent // the hostname, in which case this packet might be for us 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 " "expected: %s ]" , print_endpoint(ep).c_str() @@ -378,7 +378,7 @@ namespace libtorrent if (e) fail(e); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("<== UDP_TRACKER_PACKET [ size: %d ]", size); #endif @@ -389,14 +389,14 @@ namespace libtorrent int action = detail::read_int32(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); #endif // ignore packets with incorrect transaction id if (m_transaction_id != transaction) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ tid: %x ]" , int(transaction)); #endif @@ -412,7 +412,7 @@ namespace libtorrent // ignore packets that's not a response to our message if (action != m_state) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ unexpected action: %d " " expected: %d ]", action, m_state); #endif @@ -421,7 +421,7 @@ namespace libtorrent restart_read_timeout(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("*** UDP_TRACKER_RESPONSE [ tid: %x ]" , int(transaction)); @@ -480,13 +480,13 @@ namespace libtorrent void udp_tracker_connection::send_udp_connect() { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); #endif if (m_abort) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("==> UDP_TRACKER_CONNECT [ skipped, m_abort ]"); #endif return; @@ -518,7 +518,7 @@ namespace libtorrent ++m_attempts; if (ec) { -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) cb->debug_log("==> UDP_TRACKER_CONNECT [ failed: %s ]" , ec.message().c_str()); #endif @@ -526,7 +526,7 @@ namespace libtorrent return; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) { char hex_ih[41]; @@ -606,7 +606,7 @@ namespace libtorrent } boost::shared_ptr cb = requester(); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (cb) { boost::shared_ptr cb = requester(); @@ -755,7 +755,7 @@ namespace libtorrent TORRENT_ASSERT(out - buf <= int(sizeof(buf))); -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING boost::shared_ptr cb = requester(); if (cb) { diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index debca0e13..c6d9b91fe 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -264,7 +264,7 @@ namespace libtorrent { namespace TORRENT_ASSERT(type >= 0 && type <= 2); TORRENT_ASSERT(!m_pc.associated_torrent().expired()); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING char const* names[] = {"request", "data", "dont-have"}; char const* n = ""; if (type >= 0 && type < 3) n = names[type]; @@ -330,7 +330,7 @@ namespace libtorrent { namespace if (length > 17 * 1024) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log("<== UT_METADATA [ packet too big %d ]", length); #endif 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); if (msg.type() != entry::dictionary_t) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log("<== UT_METADATA [ not a dictionary ]"); #endif 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 || 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 ]"); #endif m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2); @@ -364,7 +364,7 @@ namespace libtorrent { namespace int type = type_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); #endif @@ -375,7 +375,7 @@ namespace libtorrent { namespace if (!m_torrent.valid_metadata() || 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 ]" , int(m_torrent.valid_metadata()), piece , int(m_tp.get_metadata_size())); @@ -399,7 +399,7 @@ namespace libtorrent { namespace // unwanted piece? if (i == m_sent_requests.end()) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log("*** UT_METADATA [ UNWANTED / TIMED OUT ]"); #endif return true; @@ -547,7 +547,7 @@ namespace libtorrent { namespace { if (m_torrent.valid_metadata()) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING source.m_pc.peer_log("*** UT_METADATA [ ALREADY HAVE METADATA ]"); #endif m_torrent.add_redundant_bytes(size, torrent::piece_unknown); @@ -559,7 +559,7 @@ namespace libtorrent { namespace // verify the total_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); #endif // #error post alert @@ -573,7 +573,7 @@ namespace libtorrent { namespace 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); #endif return false; @@ -581,7 +581,7 @@ namespace libtorrent { namespace 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 ]" , total_size, m_metadata_size); #endif diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 59ee42151..32eab15f4 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/extensions/ut_pex.hpp" -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/lazy_entry.hpp" #endif @@ -311,7 +311,7 @@ namespace libtorrent { namespace bdecode_node p = pex_msg.dict_find_string("dropped"); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING int num_dropped = 0; int num_added = 0; if (p) num_dropped += p.string_length()/6; @@ -333,7 +333,7 @@ namespace libtorrent { namespace p = pex_msg.dict_find_string("added"); 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; #endif if (p && pf && pf.string_length() == p.string_length() / 6) @@ -365,7 +365,7 @@ namespace libtorrent { namespace #if TORRENT_USE_IPV6 bdecode_node p6 = pex_msg.dict_find("dropped6"); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (p6) num_dropped += p6.string_length() / 18; #endif if (p6 != 0 && p6.type() == bdecode_node::string_t) @@ -383,7 +383,7 @@ namespace libtorrent { namespace } p6 = pex_msg.dict_find("added6"); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING if (p6) num_added += p6.string_length() / 18; #endif bdecode_node p6f = pex_msg.dict_find("added6.f"); @@ -415,7 +415,7 @@ namespace libtorrent { namespace } } #endif -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log("<== PEX [ dropped: %d added: %d ]" , num_dropped, num_added); #endif @@ -434,7 +434,7 @@ namespace libtorrent { namespace time_point now = aux::time_now(); 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 ]" , total_seconds(seconds(60) - (now - m_last_msg))); #endif @@ -452,7 +452,7 @@ namespace libtorrent { namespace 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))); #endif 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_pex); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING bdecode_node m; error_code 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_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())); #endif } diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index f4b2830ff..dd251939a 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -676,10 +676,6 @@ public: 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 , boost::uint16_t send_id, void* userdata , utp_socket_manager* sm) diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index 759ad1fbd..1fe849cb8 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -98,7 +98,7 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack // into single larger ones request_large_blocks(true); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** web_peer_connection %s", m_url.c_str()); #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) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING // a write operation failed with broken-pipe. This typically happens // with HTTP 1.0 servers that close their incoming channel of the TCP // 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() && !m_piece.empty() && m_web) { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** SAVE-RESTART-DATA: [ data: %d req: %d off: %d ]" , int(m_piece.size()), int(m_requests.front().piece) , 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; m_requests.push_back(pr); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("==> REQUESTING [ piece: %d start: %d len: %d ]" , pr.piece, pr.start, pr.length); #endif @@ -288,7 +288,7 @@ void web_peer_connection::write_request(peer_request const& r) peer_request& front = m_requests.front(); TORRENT_ASSERT(front.length > int(m_piece.size())); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** RESTART-DATA: [ data: %d req: (%d, %d) ]" , int(m_piece.size()), int(front.piece), int(front.start) , 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()); #endif @@ -441,7 +441,7 @@ bool web_peer_connection::maybe_harvest_block() buffer::const_interval recv_buffer = m_recv_buffer.get(); incoming_piece(front_request, &m_piece[0]); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]" , front_request.piece, front_request.start, front_request.length); #endif @@ -518,7 +518,7 @@ void web_peer_connection::on_receive(error_code const& error if (error) { received_bytes(0, bytes_transferred); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** web_peer_connection error: %s", error.message().c_str()); #endif #ifdef TORRENT_DEBUG @@ -556,7 +556,7 @@ void web_peer_connection::on_receive(error_code const& error if (failed) { 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()); #endif 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; } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** STATUS: %d %s", m_parser.status_code(), m_parser.message().c_str()); std::multimap const& headers = m_parser.headers(); for (std::multimap::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); } -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** LOCATION: %s", location.c_str()); #endif 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 { -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size); #endif 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); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("*** payload_transferred: %d [ %d:%d = %d ]" , payload_transferred, front_request.piece , 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)); received_bytes(0, bytes_transferred); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING std::vector sl = info.orig_files().map_block( front_request.piece, front_request.start, front_request.start + front_request.length); @@ -980,7 +980,7 @@ void web_peer_connection::on_receive(error_code const& error incoming_piece_fragment(r.length); incoming_piece(r, recv_buffer.begin); -#ifdef TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]" , r.piece, r.start, r.length); #endif diff --git a/test/test_peer_list.cpp b/test/test_peer_list.cpp index 1cc9968db..4031ea294 100644 --- a/test/test_peer_list.cpp +++ b/test/test_peer_list.cpp @@ -71,7 +71,7 @@ struct mock_peer_connection : peer_connection_interface virtual ~mock_peer_connection() {} -#if defined TORRENT_LOGGING +#if !defined TORRENT_DISABLE_LOGGING virtual void peer_log(char const* fmt, ...) const { va_list v; @@ -130,7 +130,7 @@ struct mock_torrent return true; } -#if defined TORRENT_LOGGING +#ifndef TORRENT_DISABLE_LOGGING void debug_log(const char* fmt, ...) const { va_list v;