From 9995e25be74337003f60f4064371423b25426b70 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 15 Mar 2017 07:30:30 -0400 Subject: [PATCH 1/4] fix typo --- simulation/test_tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulation/test_tracker.cpp b/simulation/test_tracker.cpp index 36fa89162..54cdc63e7 100644 --- a/simulation/test_tracker.cpp +++ b/simulation/test_tracker.cpp @@ -745,7 +745,7 @@ TORRENT_TEST(tracker_ipv6_argument) TEST_CHECK(pos != std::string::npos); got_ipv6 = pos != std::string::npos; // make sure the IPv6 argument is url encoded - TEST_CHECK(req.substr(pos + 6, req.find_first_of(pos + 6, '&')) + TEST_CHECK(req.substr(pos + 6, req.find_first_of('&', pos + 6)) == "ffff%3a%3a1337"); return sim::send_response(200, "OK", 11) + "d5:peers0:e"; } From 65cb7cdf345d5e3055e178a1313b497ee6c97ba2 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 17 Mar 2017 20:41:47 -0400 Subject: [PATCH 2/4] improve deprecated markup (#1823) improve deprecated markup --- examples/client_test.cpp | 9 ---- include/libtorrent/add_torrent_params.hpp | 26 ++++++----- include/libtorrent/alert.hpp | 13 ++---- include/libtorrent/alert_types.hpp | 54 +++++++++++------------ include/libtorrent/bencode.hpp | 2 +- include/libtorrent/config.hpp | 25 ++++++++++- include/libtorrent/create_torrent.hpp | 14 +++--- include/libtorrent/file_storage.hpp | 2 +- include/libtorrent/lazy_entry.hpp | 18 +++----- include/libtorrent/peer_class_set.hpp | 3 ++ include/libtorrent/session_handle.hpp | 31 ++++++------- include/libtorrent/settings_pack.hpp | 32 +++++++------- 12 files changed, 119 insertions(+), 110 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 413388d57..a8d0f93ca 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1255,11 +1255,6 @@ int main(int argc, char* argv[]) " -^ Set the max number of active seeds\n" "\n NETWORK OPTIONS\n" " -p sets the listen port\n" -#ifndef TORRENT_NO_DEPRECATE - " -o limits the number of simultaneous\n" - " half-open TCP connections to the\n" - " given number.\n" -#endif " -w sets the retry time for failed web seeds\n" " -x loads an emule IP-filter file\n" " -P Use the specified SOCKS5 proxy\n" @@ -1353,7 +1348,6 @@ int main(int argc, char* argv[]) p.flags |= add_torrent_params::flag_paused; p.flags &= ~add_torrent_params::flag_duplicate_is_error; p.flags |= add_torrent_params::flag_auto_managed; - p.flags |= add_torrent_params::flag_pinned; magnet_links.push_back(p); continue; } @@ -1370,9 +1364,6 @@ int main(int argc, char* argv[]) switch (argv[i][1]) { case 'f': g_log_file = fopen(arg, "w+"); break; -#ifndef TORRENT_NO_DEPRECATE - case 'o': settings.set_int(settings_pack::half_open_limit, atoi(arg)); break; -#endif case 'h': settings.set_bool(settings_pack::allow_multiple_connections_per_ip, true); --i; break; case 'p': listen_port = atoi(arg); break; case 'k': high_performance_seed(settings); --i; break; diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index db39bbabf..55b1f620d 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -68,6 +68,7 @@ namespace libtorrent // used for the torrent as long as it doesn't have metadata. See // ``torrent_handle::name``. // +#include "libtorrent/aux_/disable_warnings_push.hpp" struct TORRENT_EXPORT add_torrent_params { // The constructor can be used to initialize the storage constructor, @@ -105,6 +106,7 @@ namespace libtorrent } #ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED void update_flags() const { if (flags != (flag_ignore_flags | default_flags)) return; @@ -123,6 +125,8 @@ namespace libtorrent } #endif +#include "libtorrent/aux_/disable_warnings_pop.hpp" + // values for the ``flags`` field enum flags_t { @@ -276,7 +280,7 @@ namespace libtorrent default_flags = flag_pinned | flag_update_subscribe | flag_auto_managed | flag_paused | flag_apply_ip_filter #ifndef TORRENT_NO_DEPRECATE - , flag_ignore_flags = 0x80000000 + , flag_ignore_flags TORRENT_DEPRECATED_ENUM = 0x80000000 #endif }; @@ -288,7 +292,7 @@ namespace libtorrent boost::shared_ptr ti; #ifndef TORRENT_NO_DEPRECATE - char const* tracker_url; + char const* TORRENT_DEPRECATED_MEMBER tracker_url; #endif // If the torrent doesn't have a tracker, but relies on the DHT to find // peers, the ``trackers`` can specify tracker URLs for the torrent. @@ -408,15 +412,15 @@ namespace libtorrent int download_limit; #ifndef TORRENT_NO_DEPRECATE - bool seed_mode; - bool override_resume_data; - bool upload_mode; - bool share_mode; - bool apply_ip_filter; - bool paused; - bool auto_managed; - bool duplicate_is_error; - bool merge_resume_trackers; + bool TORRENT_DEPRECATED_MEMBER seed_mode; + bool TORRENT_DEPRECATED_MEMBER override_resume_data; + bool TORRENT_DEPRECATED_MEMBER upload_mode; + bool TORRENT_DEPRECATED_MEMBER share_mode; + bool TORRENT_DEPRECATED_MEMBER apply_ip_filter; + bool TORRENT_DEPRECATED_MEMBER paused; + bool TORRENT_DEPRECATED_MEMBER auto_managed; + bool TORRENT_DEPRECATED_MEMBER duplicate_is_error; + bool TORRENT_DEPRECATED_MEMBER merge_resume_trackers; #endif }; diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 06b48eea5..0a2e77dd2 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -89,7 +89,7 @@ namespace libtorrent { #ifndef TORRENT_NO_DEPRECATE // only here for backwards compatibility - enum severity_t { debug, info, warning, critical, fatal, none }; + enum TORRENT_DEPRECATED severity_t { debug, info, warning, critical, fatal, none }; #endif // these are bits for the alert_mask used by the session. See @@ -154,7 +154,7 @@ namespace libtorrent { // Alerts on RSS related events, like feeds being updated, feed error // conditions and successful RSS feed updates. Enabling this categoty // will make you receive rss_alert alerts. - rss_notification = 0x1000, + rss_notification TORRENT_DEPRECATED_ENUM = 0x1000, #endif // Enables debug logging alerts. These are available unless libtorrent @@ -255,10 +255,7 @@ namespace libtorrent { #ifndef TORRENT_NO_DEPRECATE -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif +#include "libtorrent/aux_/disable_warnings_push.hpp" // determines whether or not an alert is allowed to be discarded // when the alert queue is full. There are a few alerts which may not be discared, @@ -279,9 +276,7 @@ namespace libtorrent { virtual std::auto_ptr clone_impl() const = 0; -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "libtorrent/aux_/disable_warnings_pop.hpp" #endif // TORRENT_NO_DEPRECATE diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index ab482b443..027b2c8ce 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -101,7 +101,7 @@ namespace libtorrent char const* torrent_name() const; #ifndef TORRENT_NO_DEPRECATE - std::string name; + std::string TORRENT_DEPRECATED_MEMBER name; #endif protected: @@ -149,7 +149,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // The tracker URL - std::string url; + std::string TORRENT_DEPRECATED_MEMBER url; #endif private: int m_url_idx; @@ -290,7 +290,7 @@ namespace libtorrent static const int static_category = alert::storage_notification; virtual std::string message() const TORRENT_OVERRIDE; #ifndef TORRENT_NO_DEPRECATE - std::string name; + std::string TORRENT_DEPRECATED_MEMBER name; #endif char const* new_name() const; @@ -469,7 +469,7 @@ namespace libtorrent int status_code; error_code error; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif // the message associated with this error @@ -497,7 +497,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // contains the warning message from the tracker. - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif // the message associated with this warning @@ -549,7 +549,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // contains a message describing the error. - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif // the error itself. This may indicate that the tracker sent an error @@ -704,7 +704,7 @@ namespace libtorrent error_code error; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif }; @@ -752,7 +752,7 @@ namespace libtorrent close_reason_t reason; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif }; @@ -886,7 +886,7 @@ namespace libtorrent virtual std::string message() const TORRENT_OVERRIDE; #ifndef TORRENT_NO_DEPRECATE - char const* peer_speedmsg; + char const* TORRENT_DEPRECATED_MEMBER peer_speedmsg; #endif int block_index; int piece_index; @@ -925,7 +925,7 @@ namespace libtorrent virtual std::string message() const TORRENT_OVERRIDE; #ifndef TORRENT_NO_DEPRECATE - std::string path; + std::string TORRENT_DEPRECATED_MEMBER path; #endif // the path the torrent was moved to @@ -955,7 +955,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // If the error happened for a specific file, ``file`` is its path. - std::string file; + std::string TORRENT_DEPRECATED_MEMBER file; #endif // If the error happened for a specific file, this returns its path. @@ -1013,7 +1013,7 @@ namespace libtorrent sha1_hash info_hash; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif }; @@ -1053,7 +1053,7 @@ namespace libtorrent error_code error; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif }; @@ -1113,10 +1113,10 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // the HTTP seed that failed - std::string url; + std::string TORRENT_DEPRECATED_MEMBER url; // the error message, potentially from the server - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif // the error the web seed encountered. If this is not set, the server @@ -1155,7 +1155,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // the path to the file that was accessed when the error occurred. - std::string file; + std::string TORRENT_DEPRECATED_MEMBER file; #endif // the error code describing the error. @@ -1166,7 +1166,7 @@ namespace libtorrent char const* filename() const; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif private: int m_file_idx; @@ -1373,7 +1373,7 @@ namespace libtorrent // tells you what failed. error_code error; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif }; @@ -1432,7 +1432,7 @@ namespace libtorrent int map_type; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif // the message associated with this log line @@ -1470,7 +1470,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // If the error happened to a specific file, ``file`` is the path to it. - std::string file; + std::string TORRENT_DEPRECATED_MEMBER file; #endif // If the error happened to a specific file, this returns the path to it. @@ -1481,7 +1481,7 @@ namespace libtorrent char const* operation; #ifndef TORRENT_NO_DEPRECATE - std::string msg; + std::string TORRENT_DEPRECATED_MEMBER msg; #endif private: int m_path_idx; @@ -1580,16 +1580,16 @@ namespace libtorrent download_protocol, upload_ip_protocol, #ifndef TORRENT_NO_DEPRECATE - upload_dht_protocol, - upload_tracker_protocol, + upload_dht_protocol TORRENT_DEPRECATED_ENUM, + upload_tracker_protocol TORRENT_DEPRECATED_ENUM, #else deprecated1, deprecated2, #endif download_ip_protocol, #ifndef TORRENT_NO_DEPRECATE - download_dht_protocol, - download_tracker_protocol, + download_dht_protocol TORRENT_DEPRECATED_ENUM, + download_tracker_protocol TORRENT_DEPRECATED_ENUM, #else deprecated3, deprecated4, @@ -1682,7 +1682,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // The tracker ID returned by the tracker - std::string trackerid; + std::string TORRENT_DEPRECATED_MEMBER trackerid; #endif // The tracker ID returned by the tracker @@ -1769,7 +1769,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // the filename (or object) the error occurred on. - std::string error_file; + std::string TORRENT_DEPRECATED_MEMBER error_file; #endif // the filename (or object) the error occurred on. diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index a31d3629a..761b13a76 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -94,7 +94,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // thrown by bdecode() if the provided bencoded buffer does not contain // valid encoding. - struct invalid_encoding: std::exception + struct TORRENT_DEPRECATED invalid_encoding : std::exception { // hidden virtual const char* what() const TORRENT_EXCEPTION_THROW_SPECIFIER diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index e74ec158e..33b9657f4 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -92,9 +92,19 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" +// ====== CLANG ======== + +#if defined __clang__ + +# if !defined TORRENT_BUILDING_LIBRARY +// TODO: figure out which version of clang this is supported in +# define TORRENT_DEPRECATED_ENUM __attribute__ ((deprecated)) +# define TORRENT_DEPRECATED_MEMBER __attribute__ ((deprecated)) +# endif + // ======= GCC ========= -#if defined __GNUC__ +#elif defined __GNUC__ // deprecation markup is only enabled when libtorrent // headers are included by clients, not while building @@ -103,6 +113,11 @@ POSSIBILITY OF SUCH DAMAGE. # define TORRENT_DEPRECATED __attribute__ ((deprecated)) # endif +# if __GNUC__ >= 6 && !defined TORRENT_BUILDING_LIBRARY +# define TORRENT_DEPRECATED_ENUM __attribute__ ((deprecated)) +# define TORRENT_DEPRECATED_MEMBER __attribute__ ((deprecated)) +# endif + // ======= SUNPRO ========= #elif defined __SUNPRO_CC @@ -532,6 +547,14 @@ int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_DEPRECATED #endif +#ifndef TORRENT_DEPRECATED_ENUM +#define TORRENT_DEPRECATED_ENUM +#endif + +#ifndef TORRENT_DEPRECATED_MEMBER +#define TORRENT_DEPRECATED_MEMBER +#endif + #ifndef TORRENT_USE_COMMONCRYPTO #define TORRENT_USE_COMMONCRYPTO 0 #endif diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 9d05a11ba..1911c2243 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -112,7 +112,7 @@ namespace libtorrent optimize_alignment = 1, #ifndef TORRENT_NO_DEPRECATE // same as optimize_alignment, for backwards compatibility - optimize = 1, + optimize TORRENT_DEPRECATED_ENUM = 1, #endif // This will create a merkle hash tree torrent. A merkle torrent cannot @@ -443,16 +443,16 @@ namespace libtorrent // and pass in utf8 strings #ifndef TORRENT_NO_DEPRECATE - TORRENT_DEPRECATED - TORRENT_EXPORT void add_files(file_storage& fs, std::wstring const& wfile + TORRENT_DEPRECATED_EXPORT + void add_files(file_storage& fs, std::wstring const& wfile , boost::function p, boost::uint32_t flags = 0); - TORRENT_DEPRECATED - TORRENT_EXPORT void add_files(file_storage& fs, std::wstring const& wfile + TORRENT_DEPRECATED_EXPORT + void add_files(file_storage& fs, std::wstring const& wfile , boost::uint32_t flags = 0); - TORRENT_DEPRECATED - TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::wstring const& p + TORRENT_DEPRECATED_EXPORT + void set_piece_hashes(create_torrent& t, std::wstring const& p , boost::function f, error_code& ec); TORRENT_EXPORT void set_piece_hashes_deprecated(create_torrent& t diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 069397c26..b55c8ec16 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -54,7 +54,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // information about a file in a file_storage - struct TORRENT_EXPORT file_entry + struct TORRENT_DEPRECATED_EXPORT file_entry { // hidden file_entry(); diff --git a/include/libtorrent/lazy_entry.hpp b/include/libtorrent/lazy_entry.hpp index 94fdfe485..f009a5f63 100644 --- a/include/libtorrent/lazy_entry.hpp +++ b/include/libtorrent/lazy_entry.hpp @@ -81,18 +81,14 @@ namespace libtorrent // in case the function fails. ``error_pos`` is an optional pointer to an int, // which will be set to the byte offset into the buffer where an error occurred, // in case the function fails. - TORRENT_DEPRECATED - TORRENT_EXPORT int lazy_bdecode(char const* start, char const* end + TORRENT_DEPRECATED_EXPORT int lazy_bdecode(char const* start, char const* end , lazy_entry& ret, error_code& ec, int* error_pos = 0 , int depth_limit = 1000, int item_limit = 1000000); -#ifndef TORRENT_NO_DEPRECATE // for backwards compatibility, does not report error code // deprecated in 0.16 - TORRENT_DEPRECATED - TORRENT_EXPORT int lazy_bdecode(char const* start, char const* end + TORRENT_DEPRECATED_EXPORT int lazy_bdecode(char const* start, char const* end , lazy_entry& ret, int depth_limit = 1000, int item_limit = 1000000); -#endif // this is a string that is not NULL-terminated. Instead it // comes with a length, specified in bytes. This is particularly @@ -101,7 +97,7 @@ namespace libtorrent // would require copying the string. // // see lazy_entry::string_pstr(). - struct TORRENT_EXPORT pascal_string + struct TORRENT_DEPRECATED_EXPORT pascal_string { // construct a string pointing to the characters at ``p`` // of length ``l`` characters. No NULL termination is required. @@ -136,7 +132,7 @@ namespace libtorrent // // There is also a ``none`` type, which is used for uninitialized // lazy_entries. - struct TORRENT_EXPORT lazy_entry + struct TORRENT_DEPRECATED_EXPORT lazy_entry { // The different types a lazy_entry can have enum entry_type_t @@ -389,7 +385,7 @@ namespace libtorrent lazy_entry const& operator=(lazy_entry const&); }; - struct lazy_dict_entry + struct TORRENT_DEPRECATED lazy_dict_entry { char const* name; lazy_entry val; @@ -397,11 +393,11 @@ namespace libtorrent // print the bencoded structure in a human-readable format to a string // that's returned. - TORRENT_DEPRECATED - TORRENT_EXPORT std::string print_entry(lazy_entry const& e + TORRENT_DEPRECATED_EXPORT std::string print_entry(lazy_entry const& e , bool single_line = false, int indent = 0); // defined in bdecode.cpp + TORRENT_DEPRECATED TORRENT_EXTRA_EXPORT char const* parse_int(char const* start , char const* end, char delimiter, boost::int64_t& val , bdecode_errors::error_code_enum& ec); diff --git a/include/libtorrent/peer_class_set.hpp b/include/libtorrent/peer_class_set.hpp index e1e51605b..798323e06 100644 --- a/include/libtorrent/peer_class_set.hpp +++ b/include/libtorrent/peer_class_set.hpp @@ -34,7 +34,10 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_PEER_CLASS_SET_HPP_INCLUDED #include "libtorrent/peer_class.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent { diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index f56773b2e..febde8256 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -96,15 +96,15 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE , - save_as_map = 0x040, + save_as_map TORRENT_DEPRECATED_ENUM = 0x040, // saves RSS feeds - save_feeds = 0x080, - save_proxy = 0x008, - save_i2p_proxy = 0x010, - save_dht_proxy = save_proxy, - save_peer_proxy = save_proxy, - save_web_proxy = save_proxy, - save_tracker_proxy = save_proxy + save_feeds TORRENT_DEPRECATED_ENUM = 0x080, + save_proxy TORRENT_DEPRECATED_ENUM = 0x008, + save_i2p_proxy TORRENT_DEPRECATED_ENUM = 0x010, + save_dht_proxy TORRENT_DEPRECATED_ENUM = save_proxy, + save_peer_proxy TORRENT_DEPRECATED_ENUM = save_proxy, + save_web_proxy TORRENT_DEPRECATED_ENUM = save_proxy, + save_tracker_proxy TORRENT_DEPRECATED_ENUM = save_proxy #endif }; @@ -728,8 +728,8 @@ namespace libtorrent enum listen_on_flags_t { // this is always on starting with 0.16.2 - listen_reuse_address = 0x01, - listen_no_system_port = 0x02 + listen_reuse_address TORRENT_DEPRECATED_ENUM = 0x01, + listen_no_system_port TORRENT_DEPRECATED_ENUM = 0x02 }; // deprecated in 0.16 @@ -971,6 +971,8 @@ namespace libtorrent void set_alert_notify(boost::function const& fun); #ifndef TORRENT_NO_DEPRECATE +#include "libtorrent/aux_/disable_warnings_push.hpp" + TORRENT_DEPRECATED void set_severity_level(alert::severity_t s); @@ -990,11 +992,6 @@ namespace libtorrent TORRENT_DEPRECATED boost::uint32_t get_alert_mask() const; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - // This sets a function to be called (from within libtorrent's netowrk // thread) every time an alert is posted. Since the function (``fun``) is // run in libtorrent's internal thread, it may not block. @@ -1007,9 +1004,7 @@ namespace libtorrent void set_alert_dispatch( boost::function)> const& fun); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "libtorrent/aux_/disable_warnings_pop.hpp" // Starts and stops Local Service Discovery. This service will broadcast // the infohashes of all the non-private torrents on the local network to diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 76b4baae0..d7fce6165 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -75,7 +75,9 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE struct session_settings; + TORRENT_DEPRECATED settings_pack load_pack_from_struct(aux::session_settings const& current, session_settings const& s); + TORRENT_DEPRECATED void load_struct_from_settings(aux::session_settings const& current, session_settings& ret); #endif @@ -156,7 +158,7 @@ namespace libtorrent // // This feature requires the ``mmap`` system call, on systems that // don't have ``mmap`` this setting is ignored. - mmap_cache, + mmap_cache TORRENT_DEPRECATED_ENUM, #else deprecated12, #endif @@ -256,7 +258,7 @@ namespace libtorrent // if set to true, upload, download and unchoke limits are ignored for // peers on the local network. This option is *DEPRECATED*, please use // set_peer_class_filter() instead. - ignore_limits_on_local_network, + ignore_limits_on_local_network TORRENT_DEPRECATED_ENUM, #else deprecated1, #endif @@ -300,12 +302,12 @@ namespace libtorrent // pieces. use_read_cache, #ifndef TORRENT_NO_DEPRECATE - use_write_cache, + use_write_cache TORRENT_DEPRECATED_ENUM, // this will make the disk cache never flush a write piece if it would // cause is to have to re-read it once we want to calculate the piece // hash - dont_flush_write_cache, + dont_flush_write_cache TORRENT_DEPRECATED_ENUM, // ``explicit_read_cache`` defaults to 0. If set to something greater // than 0, the disk read cache will not be evicted by cache misses and @@ -315,7 +317,7 @@ namespace libtorrent // value is the number of pieces to keep in the read cache. If the // actual read cache can't fit as many, it will essentially be // clamped. - explicit_read_cache, + explicit_read_cache TORRENT_DEPRECATED_ENUM, #else deprecated7, deprecated10, @@ -388,7 +390,7 @@ namespace libtorrent // will be locked in physical RAM, never to be swapped out. Every time // a disk buffer is allocated and freed, there will be the extra // overhead of a system call. - lock_disk_cache, + lock_disk_cache TORRENT_DEPRECATED_ENUM, #else deprecated8, #endif @@ -522,7 +524,7 @@ namespace libtorrent // set to true if uTP connections should be rate limited This option // is *DEPRECATED*, please use set_peer_class_filter() instead. #ifndef TORRENT_NO_DEPRECATE - rate_limit_utp, + rate_limit_utp TORRENT_DEPRECATED_ENUM, #else deprecated2, #endif @@ -968,7 +970,7 @@ namespace libtorrent // affinity to pick pieces that are already in the cache, so that // subsequent refreshes only swaps in pieces that are rarer than // whatever is in the cache at the time. - explicit_cache_interval, + explicit_cache_interval TORRENT_DEPRECATED_ENUM, #else deprecated11, #endif @@ -1158,7 +1160,7 @@ namespace libtorrent // be useful for background tasks that doesn't matter if they take a // bit longer, as long as they leave disk I/O time for other // processes. - file_checks_delay_per_block, + file_checks_delay_per_block TORRENT_DEPRECATED_ENUM, #else deprecated14, #endif @@ -1280,8 +1282,8 @@ namespace libtorrent upload_rate_limit, download_rate_limit, #ifndef TORRENT_NO_DEPRECATE - local_upload_rate_limit, - local_download_rate_limit, + local_upload_rate_limit TORRENT_DEPRECATED_ENUM, + local_download_rate_limit TORRENT_DEPRECATED_ENUM, #else deprecated3, deprecated4, @@ -1310,7 +1312,7 @@ namespace libtorrent // have no limit. When limiting the number of simultaneous connection // attempts, peers will be put in a queue waiting for their turn to // get connected. - half_open_limit, + half_open_limit TORRENT_DEPRECATED_ENUM, #else deprecated5, #endif @@ -1367,7 +1369,7 @@ namespace libtorrent utp_num_resends, utp_connect_timeout, #ifndef TORRENT_NO_DEPRECATE - utp_delayed_ack, + utp_delayed_ack TORRENT_DEPRECATED_ENUM, #else deprecated6, #endif @@ -1422,7 +1424,7 @@ namespace libtorrent // higher than the number of CPU cores would presumably not provide // any benefit of setting it to the number of cores. If it's set to 0, // hashing is done in the disk thread. - hashing_threads, + hashing_threads TORRENT_DEPRECATED_ENUM, #else deprecated9, #endif @@ -1631,7 +1633,7 @@ namespace libtorrent { enable_os_cache = 0, #ifndef TORRENT_NO_DEPRECATE - disable_os_cache_for_aligned_files = 2, + disable_os_cache_for_aligned_files TORRENT_DEPRECATED_ENUM = 2, #else deprecated = 1, #endif From 17bc05c5821f768cf3d8c81cd62fd195eb4b9aa8 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 18 Mar 2017 00:58:06 -0400 Subject: [PATCH 3/4] improve stats counter documentation --- include/libtorrent/aux_/session_impl.hpp | 5 +++++ include/libtorrent/performance_counters.hpp | 24 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 11e067604..123182726 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -462,8 +462,13 @@ namespace libtorrent int rate_limit(peer_class_t c, int channel) const; bool preemptive_unchoke() const TORRENT_OVERRIDE; + + // deprecated, use stats counters ``num_peers_up_unchoked`` instead int num_uploads() const TORRENT_OVERRIDE { return int(m_stats_counters[counters::num_peers_up_unchoked]); } + + // deprecated, use stats counters ``num_peers_connected`` + + // ``num_peers_half_open`` instead. int num_connections() const TORRENT_OVERRIDE { return int(m_connections.size()); } int peak_up_rate() const { return m_peak_up_rate; } diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index 53170d0f9..6daf43bcf 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -347,18 +347,42 @@ namespace libtorrent num_ssl_http_proxy_peers, num_ssl_utp_peers, + // the number of peer connections that are half-open (i.e. in the + // process of completing a connection attempt) and fully connected. + // These states are mutually exclusive (a connection cannot be in both + // states simultaneously). num_peers_half_open, num_peers_connected, + + // the number of peers interested in us (``up_interested``) and peers + // we are interested in (``down_interested``). num_peers_up_interested, num_peers_down_interested, + + // the total number of unchoked peers (``up_unchoked_all``), the number + // of peers unchoked via the optimistic unchoke + // (``up_unchoked_optimistic``) and peers unchoked via the + // reciprocation (regular) unchoke mechanism (``up_unchoked``). + // and the number of peers that have unchoked us (``down_unchoked). num_peers_up_unchoked_all, num_peers_up_unchoked_optimistic, num_peers_up_unchoked, num_peers_down_unchoked, + + // the number of peers with at least one piece request pending, + // downloading (``down_requests``) or uploading (``up_requests``) num_peers_up_requests, num_peers_down_requests, + + // the number of peers that have at least one outstanding disk request, + // either reading (``up_disk``) or writing (``down_disk``). num_peers_up_disk, num_peers_down_disk, + + // the number of peers in end-game mode. End game mode is where there + // are no blocks that we have not sent any requests to download. In ths + // mode, blocks are allowed to be requested from more than one peer at + // at time. num_peers_end_game, write_cache_blocks, From ddf2c2e1ca6ab04771f5d8516d4c28a257edd7c4 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 19 Mar 2017 01:35:33 -0400 Subject: [PATCH 4/4] don't call libtorrent functions from global constructor --- examples/client_test.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index a8d0f93ca..92ce9583f 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -196,9 +196,6 @@ std::vector dht_active_requests; std::vector dht_routing_table; #endif -torrent_view view; -session_view ses_view; - int load_file(std::string const& filename, std::vector& v , libtorrent::error_code& ec, int limit = 8000000) { @@ -910,7 +907,8 @@ int save_file(std::string const& filename, std::vector& v) // returns true if the alert was handled (and should not be printed to the log) // returns false if the alert was not handled -bool handle_alert(libtorrent::session& ses, libtorrent::alert* a +bool handle_alert(torrent_view& view, session_view& ses_view + , libtorrent::session& ses, libtorrent::alert* a , handles_t& files, std::set& non_files) { using namespace libtorrent; @@ -1297,6 +1295,9 @@ int main(int argc, char* argv[]) using namespace libtorrent; namespace lt = libtorrent; + torrent_view view; + session_view ses_view; + settings_pack settings; settings.set_int(settings_pack::cache_size, cache_size); settings.set_int(settings_pack::active_loaded_limit, 20); @@ -1957,7 +1958,7 @@ int main(int argc, char* argv[]) { TORRENT_TRY { - if (!::handle_alert(ses, *i, files, non_files)) + if (!::handle_alert(view, ses_view, ses, *i, files, non_files)) { // if we didn't handle the alert, print it to the log std::string event_string; @@ -2320,7 +2321,7 @@ int main(int argc, char* argv[]) for (std::vector::iterator i = alerts.begin() , end(alerts.end()); i != end; ++i) { - if (!::handle_alert(ses, *i, files, non_files)) + if (!::handle_alert(view, ses_view, ses, *i, files, non_files)) { // if we didn't handle the alert, print it to the log std::string event_string;