From 2508e2ab0f283222dc5dbcdf63b9cf1c074b3645 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 21 Sep 2018 07:40:04 -0700 Subject: [PATCH 1/3] exposed default add_torrent_params flags to python bindings --- ChangeLog | 1 + bindings/python/src/session.cpp | 1 + bindings/python/test.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c176e1b5f..6c52329b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * exposed default add_torrent_params flags to python bindings * fix redundant flushes of partfile metadata * add option to ignore min-interval from trackers on force-reannounce * raise default setting for active_limit diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 0017ea32c..1c2969ec5 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -826,6 +826,7 @@ void bind_session() .value("flag_use_resume_save_path", add_torrent_params::flag_use_resume_save_path) .value("flag_merge_resume_http_seeds", add_torrent_params::flag_merge_resume_http_seeds) .value("flag_stop_when_ready", add_torrent_params::flag_stop_when_ready) + .value("default_flags", add_torrent_params::default_flags) ; class_("cache_status") .add_property("pieces", cache_status_pieces) diff --git a/bindings/python/test.py b/bindings/python/test.py index 1566b169d..3d57670b3 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -43,7 +43,7 @@ class test_torrent_handle(unittest.TestCase): def setup(self): self.ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False}) self.ti = lt.torrent_info('url_seed_multi.torrent'); - self.h = self.ses.add_torrent({'ti': self.ti, 'save_path': os.getcwd()}) + self.h = self.ses.add_torrent({'ti': self.ti, 'save_path': os.getcwd(), 'flags': lt.add_torrent_params_flags_t.default_flags}) def test_torrent_handle(self): self.setup() From 022a089b862870a87b7f0627afd221659731f74f Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 23 Sep 2018 06:18:23 -0700 Subject: [PATCH 2/3] utp close-reason use after free fix --- ChangeLog | 1 + src/utp_stream.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6c52329b5..2d6d1c122 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * utp close-reason fix * exposed default add_torrent_params flags to python bindings * fix redundant flushes of partfile metadata * add option to ignore min-interval from trackers on force-reannounce diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index bafd27ec0..c97836273 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -1513,7 +1513,7 @@ void utp_socket_impl::parse_close_reason(boost::uint8_t const* ptr, int size) UTP_LOGV("%8p: incoming close_reason: %d\n" , static_cast(this), int(incoming_close_reason)); - if (m_userdata == 0) return; + if (m_userdata == 0 || !m_attached) return; utp_stream::on_close_reason(m_userdata, incoming_close_reason); } From 6c4d1b9143ccc8189c218a2b68575893fc0c4879 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 21 Sep 2018 17:25:56 -0700 Subject: [PATCH 3/3] back-port the patch to split up the progress_notification alert_mask into three new categories, file-, piece- and block progress --- ChangeLog | 1 + bindings/python/src/alert.cpp | 3 +++ examples/client_test.cpp | 2 ++ include/libtorrent/alert.hpp | 21 ++++++++++++++++- include/libtorrent/alert_types.hpp | 34 ++++++++++++++++++++------- simulation/test_swarm.cpp | 2 +- test/settings.cpp | 24 +++++++++++++++---- test/setup_transfer.cpp | 9 +++++++- test/swarm_suite.cpp | 9 ++------ test/test_auto_unchoke.cpp | 4 ++-- test/test_fast_extension.cpp | 4 ++-- test/test_pex.cpp | 9 ++------ test/test_priority.cpp | 5 ---- test/test_privacy.cpp | 5 ---- test/test_read_piece.cpp | 10 ++------ test/test_recheck.cpp | 6 ++--- test/test_remap_files.cpp | 23 ++++--------------- test/test_ssl.cpp | 11 +++------ test/test_storage.cpp | 37 ++++-------------------------- test/test_torrent.cpp | 2 +- test/test_tracker.cpp | 2 -- test/test_transfer.cpp | 7 ++---- test/test_utp.cpp | 9 ++------ test/test_web_seed_redirect.cpp | 1 - test/web_seed_suite.cpp | 9 ++------ 25 files changed, 110 insertions(+), 139 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d6d1c122..63f070932 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * split progress_notification alert category into file-, piece- and block progress * utp close-reason fix * exposed default add_torrent_params flags to python bindings * fix redundant flushes of partfile metadata diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index 8a0dd0aa6..a9ec1bebb 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -226,6 +226,9 @@ void bind_alert() .value("dht_operation_notification", alert::dht_operation_notification) .value("port_mapping_log_notification", alert::port_mapping_log_notification) .value("picker_log_notification", alert::picker_log_notification) + .value("file_progress_notification", alert::file_progress_notification) + .value("piece_progress_notification", alert::piece_progress_notification) + .value("block_progress_notification", alert::block_progress_notification) // deliberately not INT_MAX. Arch linux crash while throwing an exception .value("all_categories", (alert::category_t)0xfffffff) ; diff --git a/examples/client_test.cpp b/examples/client_test.cpp index c8ce24b0d..d2cfba53b 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1539,6 +1539,8 @@ int main(int argc, char* argv[]) settings.set_str(settings_pack::user_agent, "client_test/" LIBTORRENT_VERSION); settings.set_int(settings_pack::alert_mask, alert::all_categories & ~(alert::dht_notification + + alert::piece_progress_notification + + alert::block_progress_notification + alert::progress_notification + alert::stats_notification + alert::session_log_notification diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index b2d6ecc19..f2ef02800 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -79,17 +79,25 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + // The ``alert`` class is the base class that specific messages are derived from. // alert types are not copyable, and cannot be constructed by the client. The // pointers returned by libtorrent are short lived (the details are described // under session_handle::pop_alerts()) class TORRENT_EXPORT alert { +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif public: #ifndef TORRENT_NO_DEPRECATE // only here for backwards compatibility - enum TORRENT_DEPRECATED severity_t { debug, info, warning, critical, fatal, none }; + enum TORRENT_DEPRECATED_ENUM severity_t { debug, info, warning, critical, fatal, none }; #endif // these are bits for the alert_mask used by the session. See @@ -190,6 +198,17 @@ namespace libtorrent { // enables verbose logging from the piece picker. picker_log_notification = 0x100000, + // alerts when files complete downloading + file_progress_notification = 0x200000, + + // alerts when pieces complete downloading or fail hash check + piece_progress_notification = 0x400000, + + // alerts on individual blocks being requested, downloading, finished, + // rejected, time-out and cancelled. This is likely to post alerts at a + // high rate. + block_progress_notification = 0x800000, + // The full bitmask, representing all available categories. // // since the enum is signed, make sure this isn't diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index f627fc1a2..8c3a72632 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -280,7 +280,10 @@ namespace libtorrent TORRENT_DEFINE_ALERT_PRIO(file_completed_alert, 6, alert_priority_normal) - static const int static_category = alert::progress_notification; + static const int static_category = + alert::file_progress_notification + | alert::progress_notification + ; virtual std::string message() const TORRENT_OVERRIDE; // refers to the index of the file that completed. @@ -823,7 +826,10 @@ namespace libtorrent TORRENT_DEFINE_ALERT(piece_finished_alert, 27) - static const int static_category = alert::progress_notification; + static const int static_category = + alert::piece_progress_notification + | alert::progress_notification + ; virtual std::string message() const TORRENT_OVERRIDE; // the index of the piece that finished @@ -840,8 +846,11 @@ namespace libtorrent TORRENT_DEFINE_ALERT(request_dropped_alert, 28) - static const int static_category = alert::progress_notification - | alert::peer_notification; + static const int static_category = + alert::block_progress_notification + | alert::peer_notification + | alert::progress_notification + ; virtual std::string message() const TORRENT_OVERRIDE; int block_index; @@ -858,8 +867,11 @@ namespace libtorrent TORRENT_DEFINE_ALERT(block_timeout_alert, 29) - static const int static_category = alert::progress_notification - | alert::peer_notification; + static const int static_category = + alert::block_progress_notification + | alert::peer_notification + | alert::progress_notification + ; virtual std::string message() const TORRENT_OVERRIDE; int block_index; @@ -876,7 +888,10 @@ namespace libtorrent TORRENT_DEFINE_ALERT(block_finished_alert, 30) - static const int static_category = alert::progress_notification; + static const int static_category = + alert::block_progress_notification + | alert::progress_notification + ; virtual std::string message() const TORRENT_OVERRIDE; int block_index; @@ -893,7 +908,10 @@ namespace libtorrent TORRENT_DEFINE_ALERT(block_downloading_alert, 31) - static const int static_category = alert::progress_notification; + static const int static_category = + alert::block_progress_notification + | alert::progress_notification + ; virtual std::string message() const TORRENT_OVERRIDE; #ifndef TORRENT_NO_DEPRECATE diff --git a/simulation/test_swarm.cpp b/simulation/test_swarm.cpp index 8d85b6c38..f4a84e6ba 100644 --- a/simulation/test_swarm.cpp +++ b/simulation/test_swarm.cpp @@ -445,7 +445,7 @@ TORRENT_TEST(torrent_completed_alert) // add session , [](lt::settings_pack& pack) { - pack.set_int(lt::settings_pack::alert_mask, alert::progress_notification); + pack.set_int(lt::settings_pack::alert_mask, alert::file_progress_notification); } // add torrent , [](lt::add_torrent_params&) {} diff --git a/test/settings.cpp b/test/settings.cpp index 614c732fd..988cc1d4e 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -38,11 +38,25 @@ using namespace libtorrent; libtorrent::settings_pack settings() { - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification - | alert::picker_log_notification); + const int mask = + alert::error_notification + | alert::peer_notification + | alert::port_mapping_notification + | alert::storage_notification + | alert::tracker_notification + | alert::debug_notification + | alert::status_notification + | alert::ip_block_notification + | alert::dht_notification + | alert::session_log_notification + | alert::torrent_log_notification + | alert::peer_log_notification + | alert::incoming_request_notification + | alert::dht_log_notification + | alert::dht_operation_notification + | alert::port_mapping_log_notification + | alert::file_progress_notification + | alert::piece_progress_notification; settings_pack pack; pack.set_bool(settings_pack::enable_lsd, false); diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index f1b473d88..2ce6cdba1 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -744,8 +744,15 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3 ses2->set_peer_class_filter(f); if (ses3) ses3->set_peer_class_filter(f); + const int mask = alert::all_categories + & ~(alert::progress_notification + | alert::piece_progress_notification + | alert::block_progress_notification + | alert::performance_warning + | alert::stats_notification + | alert::picker_log_notification); settings_pack pack; - pack.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification)); + pack.set_int(settings_pack::alert_mask, mask); if (ses3) pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true); pack.set_int(settings_pack::mixed_mode_algorithm, settings_pack::prefer_tcp); pack.set_int(settings_pack::max_failcount, 1); diff --git a/test/swarm_suite.cpp b/test/swarm_suite.cpp index 3be77faf7..51ede5a99 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "swarm_suite.hpp" void test_swarm(int flags) @@ -69,17 +70,11 @@ void test_swarm(int flags) session_proxy p2; session_proxy p3; - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack pack; + settings_pack pack = settings(); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - pack.set_int(settings_pack::alert_mask, mask); pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true); if (flags & strict_super_seeding) diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index 575435f29..f71b634ae 100644 --- a/test/test_auto_unchoke.cpp +++ b/test/test_auto_unchoke.cpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" void test_swarm() { @@ -59,12 +60,11 @@ void test_swarm() // three peers before finishing. float rate_limit = 50000; - settings_pack pack; + settings_pack pack = settings(); // run the choker once per second, to make it more likely to actually trigger // during the test. pack.set_int(settings_pack::unchoke_interval, 1); - pack.set_int(settings_pack::alert_mask, alert::all_categories); pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true); pack.set_int(settings_pack::choking_algorithm, settings_pack::rate_based_choker); pack.set_int(settings_pack::upload_rate_limit, rate_limit); diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index d8ac598bc..dd3f75188 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "test_utils.hpp" #include "libtorrent/socket.hpp" @@ -413,9 +414,8 @@ boost::shared_ptr setup_peer(tcp::socket& s, sha1_hash& ih { boost::shared_ptr t = ::create_torrent(); ih = t->info_hash(); - settings_pack sett; + settings_pack sett = settings(); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48900"); - sett.set_int(settings_pack::alert_mask, alert::all_categories); sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_natpmp, false); sett.set_bool(settings_pack::enable_lsd, false); diff --git a/test/test_pex.cpp b/test/test_pex.cpp index 9c9da8f40..c9282e267 100644 --- a/test/test_pex.cpp +++ b/test/test_pex.cpp @@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "setup_transfer.hpp" +#include "settings.hpp" #include void test_pex() @@ -58,16 +59,10 @@ void test_pex() session_proxy p2; session_proxy p3; - int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - // this is to avoid everything finish from a single peer // immediately. To make the swarm actually connect all // three peers before finishing. - settings_pack pack; - pack.set_int(settings_pack::alert_mask, mask); + settings_pack pack = settings(); pack.set_int(settings_pack::download_rate_limit, 2000); pack.set_int(settings_pack::upload_rate_limit, 2000); pack.set_int(settings_pack::max_retry_port_bind, 800); diff --git a/test/test_priority.cpp b/test/test_priority.cpp index bf9a6ed52..a9b68de90 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -51,8 +51,6 @@ using namespace libtorrent; namespace lt = libtorrent; using boost::tuples::ignore; -const int mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification); - int peer_disconnects = 0; bool on_alert(alert const* a) @@ -92,7 +90,6 @@ void test_transfer(settings_pack const& sett) pack.set_bool(settings_pack::enable_outgoing_utp, false); pack.set_bool(settings_pack::enable_incoming_utp, false); - pack.set_int(settings_pack::alert_mask, mask); pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled); @@ -105,7 +102,6 @@ void test_transfer(settings_pack const& sett) pack.set_bool(settings_pack::enable_dht, false); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); - pack.set_int(settings_pack::alert_mask, mask); #ifndef TORRENT_NO_DEPRECATE pack.set_bool(settings_pack::rate_limit_utp, true); #endif @@ -113,7 +109,6 @@ void test_transfer(settings_pack const& sett) lt::session ses1(pack); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); - pack.set_int(settings_pack::alert_mask, mask); lt::session ses2(pack); torrent_handle tor1; diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp index 0a0b1eefa..23bf27c57 100644 --- a/test/test_privacy.cpp +++ b/test/test_privacy.cpp @@ -98,10 +98,6 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags) int const prev_udp_announces = num_udp_announces(); - int const alert_mask = alert::all_categories - & ~alert::progress_notification - & ~alert::stats_notification; - settings_pack sett = settings(); sett.set_int(settings_pack::stop_tracker_timeout, 2); sett.set_int(settings_pack::tracker_completion_timeout, 2); @@ -109,7 +105,6 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags) sett.set_bool(settings_pack::announce_to_all_trackers, true); sett.set_bool(settings_pack::announce_to_all_tiers, true); sett.set_bool(settings_pack::force_proxy, flags & force_proxy_mode); - sett.set_int(settings_pack::alert_mask, alert_mask); sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_natpmp, false); sett.set_bool(settings_pack::enable_lsd, false); diff --git a/test/test_read_piece.cpp b/test/test_read_piece.cpp index 011c0986e..100ba3d29 100644 --- a/test/test_read_piece.cpp +++ b/test/test_read_piece.cpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session.hpp" #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "libtorrent/create_torrent.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/torrent_info.hpp" @@ -88,19 +89,12 @@ void test_read_piece(int flags) fprintf(stderr, "generated torrent: %s tmp1_read_piece/test_torrent\n" , to_hex(ti->info_hash().to_string()).c_str()); - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack sett; + settings_pack sett = settings(); sett.set_bool(settings_pack::enable_lsd, false); sett.set_bool(settings_pack::enable_natpmp, false); sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_dht, false); - sett.set_int(settings_pack::alert_mask, mask); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48000"); - sett.set_int(settings_pack::alert_mask, alert::all_categories); lt::session ses(sett); add_torrent_params p; diff --git a/test/test_recheck.cpp b/test/test_recheck.cpp index 4b290e7ee..039d95f83 100644 --- a/test/test_recheck.cpp +++ b/test/test_recheck.cpp @@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include #include @@ -51,8 +52,6 @@ POSSIBILITY OF SUCH DAMAGE. using namespace libtorrent; namespace lt = libtorrent; -const int mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification); - void wait_for_complete(lt::session& ses, torrent_handle h) { int last_progress = 0; @@ -77,9 +76,8 @@ void wait_for_complete(lt::session& ses, torrent_handle h) TORRENT_TEST(recheck) { error_code ec; - settings_pack sett; + settings_pack sett = settings(); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48675"); - sett.set_int(settings_pack::alert_mask, mask); sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_natpmp, false); sett.set_bool(settings_pack::enable_lsd, false); diff --git a/test/test_remap_files.cpp b/test/test_remap_files.cpp index e327c48f1..7d285b8fe 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/create_torrent.hpp" #include "libtorrent/torrent_info.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "test.hpp" #include @@ -69,20 +70,15 @@ void test_remap_files_gather(storage_mode_t storage_mode = storage_mode_sparse) // in case the previous run was terminated error_code ec; - int const alert_mask = alert::all_categories - & ~alert::progress_notification - & ~alert::stats_notification; - session_proxy p1; session_proxy p2; - settings_pack sett; + settings_pack sett = settings(); sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_natpmp, false); sett.set_bool(settings_pack::enable_lsd, false); sett.set_bool(settings_pack::enable_dht, false); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); - sett.set_int(settings_pack::alert_mask, alert_mask); lt::session ses1(sett); @@ -231,25 +227,19 @@ void test_remap_files_scatter(storage_mode_t storage_mode = storage_mode_sparse) // in case the previous run was terminated error_code ec; - int const alert_mask = alert::all_categories - & ~alert::progress_notification - & ~alert::stats_notification; - session_proxy p1; session_proxy p2; - settings_pack sett; + settings_pack sett = settings(); sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_natpmp, false); sett.set_bool(settings_pack::enable_lsd, false); sett.set_bool(settings_pack::enable_dht, false); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); - sett.set_int(settings_pack::alert_mask, alert_mask); lt::session ses1(sett); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); - sett.set_int(settings_pack::alert_mask, alert_mask); lt::session ses2(sett); torrent_handle tor1; @@ -374,20 +364,15 @@ void test_remap_files_prio(storage_mode_t storage_mode = storage_mode_sparse) // in case the previous run was terminated error_code ec; - int const alert_mask = alert::all_categories - & ~alert::progress_notification - & ~alert::stats_notification; - session_proxy p1; session_proxy p2; - settings_pack sett; + settings_pack sett = settings(); sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_natpmp, false); sett.set_bool(settings_pack::enable_lsd, false); sett.set_bool(settings_pack::enable_dht, false); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); - sett.set_int(settings_pack::alert_mask, alert_mask); lt::session ses1(sett); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:49075"); diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index 998cc7e81..7685cedec 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "test_utils.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" @@ -58,10 +59,6 @@ POSSIBILITY OF SUCH DAMAGE. using namespace libtorrent; using boost::tuples::ignore; -int const alert_mask = alert::all_categories -& ~alert::progress_notification -& ~alert::stats_notification; - struct test_config_t { char const* name; @@ -132,8 +129,7 @@ void test_ssl(int const test_idx, bool const use_utp) remove_all("tmp2_ssl", ec); int ssl_port = 1024 + rand() % 50000; - settings_pack sett; - sett.set_int(settings_pack::alert_mask, alert_mask); + settings_pack sett = settings(); sett.set_int(settings_pack::max_retry_port_bind, 100); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); sett.set_bool(settings_pack::enable_incoming_utp, use_utp); @@ -544,8 +540,7 @@ void test_malicious_peer() // set up session int ssl_port = 1024 + rand() % 50000; - settings_pack sett; - sett.set_int(settings_pack::alert_mask, alert_mask); + settings_pack sett = settings(); sett.set_int(settings_pack::max_retry_port_bind, 100); sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); sett.set_int(settings_pack::ssl_listen, ssl_port); diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 9aa4f5fc9..47c5bd2d2 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -659,17 +659,11 @@ TORRENT_TEST(fastresume) entry resume; { - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack pack; + settings_pack pack = settings(); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - pack.set_int(settings_pack::alert_mask, mask); lt::session ses(pack); error_code ec; @@ -720,17 +714,11 @@ TORRENT_TEST(fastresume) // make sure the fast resume check fails! since we removed the file { - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack pack; + settings_pack pack = settings(); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - pack.set_int(settings_pack::alert_mask, mask); lt::session ses(pack); add_torrent_params p; @@ -765,12 +753,7 @@ TORRENT_TEST(rename_file) file_storage fs; boost::shared_ptr info = setup_torrent_info(fs, buf); - const int mask = alert::all_categories - & ~(alert::performance_warning - | alert::stats_notification); - settings_pack pack = settings(); - pack.set_int(settings_pack::alert_mask, mask); pack.set_bool(settings_pack::disable_hash_checks, true); lt::session ses(pack); @@ -835,17 +818,11 @@ TORRENT_TEST(rename_file_fastresume) entry resume; { - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack pack; + settings_pack pack = settings(); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - pack.set_int(settings_pack::alert_mask, mask); lt::session ses(pack); add_torrent_params p; @@ -883,17 +860,11 @@ TORRENT_TEST(rename_file_fastresume) // make sure the fast resume check succeeds, even though we renamed the file { - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack pack; + settings_pack pack = settings(); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - pack.set_int(settings_pack::alert_mask, mask); lt::session ses(pack); add_torrent_params p; diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 49bf5ce50..5c60e137a 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -79,7 +79,7 @@ bool prioritize_files(torrent_handle const& h, std::vector const& prio) void test_running_torrent(boost::shared_ptr info, boost::int64_t file_size) { settings_pack pack = settings(); - pack.set_int(settings_pack::alert_mask, alert::progress_notification | alert::storage_notification); + pack.set_int(settings_pack::alert_mask, alert::piece_progress_notification | alert::storage_notification); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48130"); pack.set_int(settings_pack::max_retry_port_bind, 10); lt::session ses(pack); diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index 9375c71a9..ac53b3474 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -492,7 +492,6 @@ TORRENT_TEST(current_tracker) pack.set_int(settings_pack::tracker_completion_timeout, 2); pack.set_int(settings_pack::tracker_receive_timeout, 1); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:39775"); - //pack.set_int(settings_pack::alert_mask, alert::tracker_notification); boost::scoped_ptr s(new lt::session(pack)); @@ -649,7 +648,6 @@ void test_stop_tracker_timeout(int const timeout) settings_pack p = settings(); p.set_bool(settings_pack::announce_to_all_trackers, true); p.set_bool(settings_pack::announce_to_all_tiers, true); - p.set_int(settings_pack::alert_mask, alert::all_categories); p.set_str(settings_pack::listen_interfaces, "0.0.0.0:6881"); p.set_int(settings_pack::stop_tracker_timeout, timeout); diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index 91c97fada..7f7e44a7c 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "test_utils.hpp" #include @@ -55,8 +56,6 @@ namespace lt = libtorrent; using boost::tuples::ignore; -const int mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification); - int peer_disconnects = 0; bool on_alert(alert const* a) @@ -145,9 +144,8 @@ void test_transfer(int proxy_type, settings_pack const& sett session_proxy p1; session_proxy p2; - settings_pack pack; + settings_pack pack = settings(); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075"); - pack.set_int(settings_pack::alert_mask, mask); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_natpmp, false); @@ -204,7 +202,6 @@ void test_transfer(int proxy_type, settings_pack const& sett pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - pack.set_int(settings_pack::alert_mask, mask); pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled); diff --git a/test/test_utp.cpp b/test/test_utp.cpp index 767e1a177..21385dc25 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include #include @@ -63,17 +64,11 @@ void test_transfer() session_proxy p1; session_proxy p2; - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack pack; + settings_pack pack = settings(); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - pack.set_int(settings_pack::alert_mask, mask); pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled); pack.set_bool(settings_pack::enable_outgoing_tcp, false); diff --git a/test/test_web_seed_redirect.cpp b/test/test_web_seed_redirect.cpp index 860820e34..4db8ba522 100644 --- a/test/test_web_seed_redirect.cpp +++ b/test/test_web_seed_redirect.cpp @@ -91,7 +91,6 @@ TORRENT_TEST(web_seed_redirect) { settings_pack p = settings(); p.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024); - p.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification)); libtorrent::session ses(p); // disable keep-alive because otherwise the test will choke on seeing diff --git a/test/web_seed_suite.cpp b/test/web_seed_suite.cpp index 31a754c60..51cb4f672 100644 --- a/test/web_seed_suite.cpp +++ b/test/web_seed_suite.cpp @@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "web_seed_suite.hpp" #include "make_torrent.hpp" @@ -392,16 +393,10 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed } { - const int mask = alert::all_categories - & ~(alert::progress_notification - | alert::performance_warning - | alert::stats_notification); - - settings_pack pack; + settings_pack pack = settings(); pack.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:51000"); pack.set_int(settings_pack::max_retry_port_bind, 1000); - pack.set_int(settings_pack::alert_mask, mask); pack.set_bool(settings_pack::enable_lsd, false); pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false);