diff --git a/include/libtorrent/address.hpp b/include/libtorrent/address.hpp index 02461dc2e..737152baf 100644 --- a/include/libtorrent/address.hpp +++ b/include/libtorrent/address.hpp @@ -35,28 +35,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#ifdef __OBJC__ -#define Protocol Protocol_ -#endif - -#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN -// asio assumes that the windows error codes are defined already -#include -#endif - -#include - #if defined TORRENT_BUILD_SIMULATOR #include "simulator/simulator.hpp" -#endif - +#else +#include "libtorrent/aux_/disable_warnings_push.hpp" +#include #include "libtorrent/aux_/disable_warnings_pop.hpp" - -#ifdef __OBJC__ -#undef Protocol -#endif +#endif // SIMULATOR namespace libtorrent { diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 328f27a20..af7c7a6a9 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_ALERT_HPP_INCLUDED #define TORRENT_ALERT_HPP_INCLUDED -#include #include // OVERVIEW diff --git a/include/libtorrent/announce_entry.hpp b/include/libtorrent/announce_entry.hpp index e3a920674..f8d1caf4e 100644 --- a/include/libtorrent/announce_entry.hpp +++ b/include/libtorrent/announce_entry.hpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_ANNOUNCE_ENTRY_HPP_INCLUDED #include "libtorrent/config.hpp" -#include "libtorrent/time.hpp" // for time_point +#include "libtorrent/time.hpp" #include "libtorrent/error_code.hpp" #include @@ -42,10 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - namespace aux { - struct session_settings; - } - // this class holds information about one bittorrent tracker, as it // relates to a specific torrent. struct TORRENT_EXPORT announce_entry @@ -161,7 +157,7 @@ namespace libtorrent // updates the failure counter and time-outs for re-trying. // This is called when the tracker announce fails. - void failed(aux::session_settings const& sett, int retry_interval = 0); + void failed(time_duration tracker_backoff, int retry_interval = 0); #ifndef TORRENT_NO_DEPRECATE // deprecated in 1.0 diff --git a/include/libtorrent/aux_/proxy_settings.hpp b/include/libtorrent/aux_/proxy_settings.hpp index 83d6479d2..add73c473 100644 --- a/include/libtorrent/aux_/proxy_settings.hpp +++ b/include/libtorrent/aux_/proxy_settings.hpp @@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PROXY_SETTINGS_HPP_INCLUDED #define TORRENT_PROXY_SETTINGS_HPP_INCLUDED -#include "libtorrent/version.hpp" #include "libtorrent/config.hpp" #include @@ -138,8 +137,6 @@ namespace aux { }; -} -} +}} #endif - diff --git a/include/libtorrent/aux_/session_settings.hpp b/include/libtorrent/aux_/session_settings.hpp index c9ba58961..74ab04b56 100644 --- a/include/libtorrent/aux_/session_settings.hpp +++ b/include/libtorrent/aux_/session_settings.hpp @@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_AUX_SESSION_SETTINGS_HPP_INCLUDED #define TORRENT_AUX_SESSION_SETTINGS_HPP_INCLUDED -#include "libtorrent/version.hpp" #include "libtorrent/config.hpp" #include "libtorrent/settings_pack.hpp" #include "libtorrent/assert.hpp" @@ -102,4 +101,3 @@ namespace libtorrent { namespace aux } } #endif - diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index dfade87c6..fae283795 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -45,6 +45,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/dht_storage.hpp" +#ifndef TORRENT_NO_DEPRECATE +#include +#endif + namespace libtorrent { struct plugin; diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 5a2fe27a8..c42b62959 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -61,7 +61,8 @@ namespace libtorrent TORRENT_EXTRA_EXPORT boost::shared_ptr load_pack_from_dict(bdecode_node const& settings); TORRENT_EXTRA_EXPORT void save_settings_to_dict(aux::session_settings const& s, entry::dictionary_type& sett); - TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett, aux::session_impl* ses = 0); + TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett + , aux::session_impl* ses = nullptr); TORRENT_EXPORT int setting_by_name(std::string const& name); TORRENT_EXPORT char const* name_for_setting(int s); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index ca6f17476..012fad0cc 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -1223,7 +1223,7 @@ namespace libtorrent // directory, if there is one. The source files will still be removed in // that case. // - // Files that have been renamed to have absolute pahts are not moved by + // Files that have been renamed to have absolute paths are not moved by // this function. Keep in mind that files that don't belong to the // torrent but are stored in the torrent's directory may be moved as // well. This goes for files that have been renamed to absolute paths diff --git a/src/announce_entry.cpp b/src/announce_entry.cpp index d0c110253..3f3d7e8d5 100644 --- a/src/announce_entry.cpp +++ b/src/announce_entry.cpp @@ -41,10 +41,10 @@ namespace libtorrent enum { // wait at least 5 seconds before retrying a failed tracker - tracker_retry_delay_min = 5 + tracker_retry_delay_min = 5, // when tracker_failed_max trackers // has failed, wait 60 minutes instead - , tracker_retry_delay_max = 60 * 60 + tracker_retry_delay_max = 60 * 60 }; announce_entry::announce_entry(std::string const& u) @@ -99,14 +99,15 @@ namespace libtorrent min_announce = min_time(); } - void announce_entry::failed(aux::session_settings const& sett, int retry_interval) + void announce_entry::failed(time_duration const tracker_backoff, int const retry_interval) { ++fails; // the exponential back-off ends up being: // 7, 15, 27, 45, 95, 127, 165, ... seconds // with the default tracker_backoff of 250 + int const tracker_backoff_seconds = total_seconds(tracker_backoff); int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails) - * tracker_retry_delay_min * sett.get_int(settings_pack::tracker_backoff) / 100 + * tracker_retry_delay_min * tracker_backoff_seconds / 100 , int(tracker_retry_delay_max)); delay = (std::max)(delay, retry_interval); next_announce = aux::time_now() + seconds(delay); diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 5860f7626..bb167f3dd 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -42,7 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/alert_manager.hpp" -#include #include #include @@ -55,9 +54,6 @@ using namespace std::placeholders; namespace libtorrent { - - class alert; - namespace { inline bool default_pred(std::string const&) { return true; } @@ -740,6 +736,4 @@ namespace libtorrent if (str == nullptr) m_created_by.clear(); else m_created_by = str; } - } - diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index adf30e3ed..d042ba4fc 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -36,18 +36,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/allocator.hpp" #include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/io_service.hpp" -#include "libtorrent/alert.hpp" -#include "libtorrent/alert_types.hpp" #include "libtorrent/disk_observer.hpp" #include "libtorrent/platform_util.hpp" // for total_physical_ram #include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include -#include -#include - #if TORRENT_HAVE_MMAP #include #endif diff --git a/src/proxy_settings.cpp b/src/proxy_settings.cpp index 807896d3c..55c04f293 100644 --- a/src/proxy_settings.cpp +++ b/src/proxy_settings.cpp @@ -75,4 +75,3 @@ proxy_settings::proxy_settings(aux::session_settings const& sett) } // namespace aux } // namespace libtorrent - diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 293c86201..0ac7e1eec 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -32,13 +32,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include #include #include @@ -91,10 +84,10 @@ namespace // CRCs from the time it failed and ban the peers that // sent bad blocks std::map::iterator i = m_block_hashes.lower_bound(piece_block(p, 0)); - if (i == m_block_hashes.end() || int(i->first.piece_index) != p) return; + if (i == m_block_hashes.end() || i->first.piece_index != p) return; int size = m_torrent.torrent_file().piece_size(p); - peer_request r = {p, 0, (std::min)(16*1024, size)}; + peer_request r = {p, 0, (std::min)(16 * 1024, size)}; piece_block pb(p, 0); while (size > 0) { @@ -114,9 +107,9 @@ namespace if (i == m_block_hashes.end() || int(i->first.piece_index) != p) break; - r.start += 16*1024; - size -= 16*1024; - r.length = (std::min)(16*1024, size); + r.start += 16 * 1024; + size -= 16 * 1024; + r.length = (std::min)(16 * 1024, size); ++pb.block_index; } diff --git a/src/storage.cpp b/src/storage.cpp index d97891d65..80d28672c 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -610,7 +610,6 @@ namespace libtorrent { m_stat_cache.reserve(files().num_files()); - std::string file_path; for (int i = 0; i < files().num_files(); ++i) { std::int64_t sz = m_stat_cache.get_filesize( @@ -1541,7 +1540,7 @@ namespace libtorrent // check if the fastresume data is up to date // if it is, use it and return true. If it // isn't return false and the full check - // will be run. If the links pointer is non-nullptr, it has the same number + // will be run. If the links pointer is non-empty, it has the same number // of elements as there are files. Each element is either empty or contains // the absolute path to a file identical to the corresponding file in this // torrent. The storage must create hard links (or copy) those files. If diff --git a/src/torrent.cpp b/src/torrent.cpp index 800b75332..78891bc8d 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -11256,7 +11256,8 @@ namespace libtorrent announce_entry* ae = find_tracker(r); if (ae) { - ae->failed(settings(), retry_interval); + ae->failed(seconds(settings().get_int(settings_pack::tracker_backoff)) + , retry_interval); ae->last_error = ec; ae->message = msg; int tracker_index = ae - &m_trackers[0]; @@ -11272,7 +11273,7 @@ namespace libtorrent || r.triggered_manually) { m_ses.alerts().emplace_alert(get_handle() - , ae?ae->fails:0, response_code, r.url, ec, msg); + , ae ? ae->fails : 0, response_code, r.url, ec, msg); } } else diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 8898b9a06..0f29c3de2 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -80,7 +80,7 @@ namespace libtorrent } // anonymous namespace // fixes invalid UTF-8 sequences - TORRENT_EXTRA_EXPORT bool verify_encoding(std::string& target) + bool verify_encoding(std::string& target) { if (target.empty()) return true; diff --git a/src/torrent_peer.cpp b/src/torrent_peer.cpp index 393cd1ac0..7881ee164 100644 --- a/src/torrent_peer.cpp +++ b/src/torrent_peer.cpp @@ -107,13 +107,13 @@ namespace libtorrent if (e1 > e2) swap(e1, e2); address_v6::bytes_type b1 = e1.address().to_v6().to_bytes(); address_v6::bytes_type b2 = e2.address().to_v6().to_bytes(); - int mask = memcmp(&b1[0], &b2[0], 4) ? 0 - : memcmp(&b1[0], &b2[0], 6) ? 1 : 2; - apply_mask(&b1[0], v6mask[mask], 8); - apply_mask(&b2[0], v6mask[mask], 8); + int const mask = std::memcmp(b1.data(), b2.data(), 4) ? 0 + : std::memcmp(b1.data(), b2.data(), 6) ? 1 : 2; + apply_mask(b1.data(), v6mask[mask], 8); + apply_mask(b2.data(), v6mask[mask], 8); std::uint64_t addrbuf[4]; - memcpy(&addrbuf[0], &b1[0], 16); - memcpy(&addrbuf[2], &b2[0], 16); + memcpy(&addrbuf[0], b1.data(), 16); + memcpy(&addrbuf[2], b2.data(), 16); ret = crc32c(addrbuf, 4); } #endif @@ -313,4 +313,3 @@ namespace libtorrent } } - diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index f649d4387..752b590f9 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -32,18 +32,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include #include - #include #include #include #include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/peer_connection_handle.hpp" diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 2294ce07a..13ab9bd22 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -71,11 +71,10 @@ TORRENT_TEST(primitives) // on failing announces announce_entry ae("dummy"); int last = 0; - aux::session_settings sett; - sett.set_int(settings_pack::tracker_backoff, 250); + auto const tracker_backoff = seconds(250); for (int i = 0; i < 10; ++i) { - ae.failed(sett, 5); + ae.failed(tracker_backoff, 5); int delay = ae.next_announce_in(); TEST_CHECK(delay > last); last = delay;