diff --git a/ChangeLog b/ChangeLog index 0b3d7b8c9..6a014d80d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -88,6 +88,9 @@ * resume data no longer has timestamps of files * require C++11 to build libtorrent + * 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 * 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 2a0196506..5e0d6fd59 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -836,6 +836,7 @@ void bind_session() s.attr("stop_when_ready") = torrent_flags::stop_when_ready; s.attr("override_trackers") = torrent_flags::override_trackers; s.attr("override_web_seeds") = torrent_flags::override_web_seeds; + s.attr("default_flags") = torrent_flags::default_flags; } #if TORRENT_ABI_VERSION == 1 @@ -859,6 +860,7 @@ void bind_session() s.attr("flag_merge_resume_trackers") = add_torrent_params::flag_merge_resume_trackers; s.attr("flag_use_resume_save_path") = add_torrent_params::flag_use_resume_save_path; s.attr("flag_merge_resume_http_seeds") = add_torrent_params::flag_merge_resume_http_seeds; + s.attr("default_flags") = add_torrent_params::flag_default_flags; } #endif diff --git a/bindings/python/test.py b/bindings/python/test.py index 6e6c75e27..40760452d 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -70,7 +70,8 @@ class test_torrent_handle(unittest.TestCase): self.ses = lt.session(settings) self.ti = lt.torrent_info('url_seed_multi.torrent') self.h = self.ses.add_torrent({ - 'ti': self.ti, 'save_path': os.getcwd()}) + 'ti': self.ti, 'save_path': os.getcwd(), + 'flags': lt.torrent_flags.default_flags}) def test_torrent_handle(self): self.setup() @@ -536,7 +537,8 @@ class test_session(unittest.TestCase): self.assertEqual(s.get_settings()['user_agent'], 'test123') def test_post_session_stats(self): - s = lt.session({'alert_mask': lt.alert.category_t.stats_notification, 'enable_dht': False}) + s = lt.session({'alert_mask': lt.alert.category_t.stats_notification, + 'enable_dht': False}) s.post_session_stats() alerts = [] # first the stats headers log line. but not if logging is disabled diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index 5f811eeca..accae1199 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -1447,7 +1447,7 @@ void utp_socket_impl::parse_close_reason(std::uint8_t const* ptr, int const size UTP_LOGV("%8p: incoming close_reason: %d\n" , static_cast(this), int(incoming_close_reason)); - if (m_userdata == nullptr) return; + if (m_userdata == nullptr || !m_attached) return; utp_stream::on_close_reason(m_userdata, incoming_close_reason); } diff --git a/test/settings.cpp b/test/settings.cpp index 27c983b67..6cc300010 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -38,14 +38,25 @@ using namespace lt; lt::settings_pack settings() { - auto const mask = alert::all_categories - & ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | alert::stats_notification - | alert::picker_log_notification); + alert_category_t const 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 f020a6918..3490e2af2 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -794,16 +794,7 @@ 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); - auto const mask = alert::all_categories - & ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | alert::stats_notification); - settings_pack pack; - 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 e17990d97..d111cd8d5 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "swarm_suite.hpp" #ifdef _MSC_VER @@ -75,19 +76,7 @@ void test_swarm(test_flags_t const flags) session_proxy p2; session_proxy p3; - auto const mask = ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | alert::stats_notification); - - settings_pack pack; - 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); + settings_pack pack = settings(); pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true); if (flags & test_flags::strict_super_seeding) diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index 17277490b..b3ef46285 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" namespace { @@ -60,12 +61,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, int(rate_limit)); diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index 6feab4a97..6cedbdff7 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" @@ -420,9 +421,8 @@ std::shared_ptr setup_peer(tcp::socket& s, sha1_hash& ih { std::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 4104670d6..38c7cc404 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 namespace { @@ -59,18 +60,10 @@ void test_pex() session_proxy p2; session_proxy p3; - auto const mask = ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | 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 975c18128..587ec6380 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -54,8 +54,6 @@ using std::ignore; namespace { -alert_category_t const mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification); - int peer_disconnects = 0; bool on_alert(alert const* a) @@ -95,7 +93,6 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false) 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); @@ -108,7 +105,6 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false) 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); #if TORRENT_ABI_VERSION == 1 pack.set_bool(settings_pack::rate_limit_utp, true); #endif @@ -116,7 +112,6 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false) 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; @@ -403,7 +398,7 @@ TORRENT_TEST(priority) TORRENT_TEST(priority_deprecated) { using namespace lt; - settings_pack p; + settings_pack p = settings(); test_transfer(p, true); cleanup(); } diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp index 3224293b8..2a1a75cd1 100644 --- a/test/test_privacy.cpp +++ b/test/test_privacy.cpp @@ -87,20 +87,12 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, flags_t flags) int const prev_udp_announces = num_udp_announces(); - auto const alert_mask = ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | 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); sett.set_int(settings_pack::tracker_receive_timeout, 2); sett.set_bool(settings_pack::announce_to_all_trackers, true); sett.set_bool(settings_pack::announce_to_all_tiers, true); - 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 dbaf53eb0..77b3d8233 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" @@ -90,21 +91,8 @@ void test_read_piece(int flags) std::printf("generated torrent: %s tmp1_read_piece/test_torrent\n" , aux::to_hex(ti->info_hash()).c_str()); - auto const mask = ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | alert::stats_notification); - - settings_pack sett; - 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); + settings_pack sett = settings(); 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 4faf61294..f62610784 100644 --- a/test/test_recheck.cpp +++ b/test/test_recheck.cpp @@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include #include @@ -51,8 +52,6 @@ using namespace lt; namespace { -auto const mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification); - void wait_for_complete(lt::session& ses, torrent_handle h) { int last_progress = 0; @@ -81,9 +80,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 0a5c36a76..f44c1ba2f 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_info.hpp" #include "libtorrent/aux_/path.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "test.hpp" #include "settings.hpp" diff --git a/test/test_settings_pack b/test/test_settings_pack new file mode 100755 index 000000000..16686d41f Binary files /dev/null and b/test/test_settings_pack differ diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index f2f193aee..63a1ae75f 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -42,6 +42,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" @@ -63,10 +64,6 @@ using std::ignore; namespace { -auto const alert_mask = alert::all_categories - & ~alert::progress_notification - & ~alert::stats_notification; - struct test_config_t { char const* name; @@ -144,8 +141,7 @@ void test_ssl(int const test_idx, bool const use_utp) remove_all("tmp2_ssl", ec); int 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); char listen_iface[100]; @@ -553,8 +549,7 @@ void test_malicious_peer() // set up session int 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); char listen_iface[100]; diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 99695991e..11e50e41b 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -800,12 +800,7 @@ TORRENT_TEST(rename_file) file_storage fs; std::shared_ptr info = setup_torrent_info(fs, buf); - auto const 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); diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 46ce67a04..ef347d31a 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -78,7 +78,7 @@ bool prioritize_files(torrent_handle const& h, aux::vector info, std::int64_t file_size) { settings_pack pack = settings(); - pack.set_int(settings_pack::alert_mask, alert::file_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 0e8004b63..e7ca3c2fe 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -506,7 +506,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); std::unique_ptr s(new lt::session(pack)); @@ -665,7 +664,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 98668a25b..d1ce33c2f 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" +#include "settings.hpp" #include "test_utils.hpp" #include @@ -55,9 +56,6 @@ using std::ignore; namespace { -auto const mask = alert::all_categories - & ~(alert::performance_warning | alert::stats_notification); - int peer_disconnects = 0; bool on_alert(alert const* a) @@ -154,9 +152,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); @@ -212,7 +209,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 ddabdbd1f..8eaf689be 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 using namespace lt; @@ -62,19 +63,11 @@ void test_transfer() session_proxy p1; session_proxy p2; - auto const mask = ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | 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 defb811cb..75724311f 100644 --- a/test/test_web_seed_redirect.cpp +++ b/test/test_web_seed_redirect.cpp @@ -88,16 +88,8 @@ TORRENT_TEST(web_seed_redirect) auto torrent_file = std::make_shared(buf, ec, from_span); { - auto const mask = ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | alert::stats_notification); - settings_pack p = settings(); p.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024); - p.set_int(settings_pack::alert_mask, mask); lt::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 91522bb82..0b40f3f59 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" @@ -391,19 +392,10 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed } { - auto const mask = alert::all_categories - & ~( - alert::performance_warning -#if TORRENT_ABI_VERSION == 1 - | alert::progress_notification -#endif - | 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);