From be10ccd88108c4eff9150af1c6c9048446667900 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 20 Mar 2020 00:10:47 +0100 Subject: [PATCH] deprecate strict super seeding mode --- ChangeLog | 1 + include/libtorrent/settings_pack.hpp | 6 +++++- simulation/test_super_seeding.cpp | 4 ++++ src/peer_connection.cpp | 10 ++++++++-- src/settings_pack.cpp | 2 +- src/torrent.cpp | 2 ++ src/torrent_handle.cpp | 11 ++++++++++- test/swarm_suite.cpp | 2 ++ 8 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8dce4be8..7627e7ad0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * deprecate strict super seeding mode * make UPnP port-mapping lease duration configurable * deprecate the bittyrant choking algorithm * add build option to disable streaming diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 670888464..ece8e61bc 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -425,10 +425,14 @@ namespace aux { // preference of one protocol over another. prefer_udp_trackers, +#if TORRENT_ABI_VERSION == 1 // ``strict_super_seeding`` when this is set to true, a piece has to // have been forwarded to a third peer before another one is handed // out. This is the traditional definition of super seeding. - strict_super_seeding, + strict_super_seeding TORRENT_DEPRECATED_ENUM, +#else + deprecated_strict_super_seeding, +#endif #if TORRENT_ABI_VERSION == 1 // if this is set to true, the memory allocated for the disk cache diff --git a/simulation/test_super_seeding.cpp b/simulation/test_super_seeding.cpp index c173550a6..b027b7de4 100644 --- a/simulation/test_super_seeding.cpp +++ b/simulation/test_super_seeding.cpp @@ -54,6 +54,7 @@ TORRENT_TEST(super_seeding) { return true; }); } +#if TORRENT_ABI_VERSION == 1 TORRENT_TEST(strict_super_seeding) { setup_swarm(5, swarm_test::upload @@ -72,3 +73,6 @@ TORRENT_TEST(strict_super_seeding) { return true; }); } #endif +#else +TORRENT_TEST(summy) {} +#endif diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index ac7ee7520..2a2446138 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1944,7 +1944,11 @@ namespace libtorrent { } #ifndef TORRENT_DISABLE_SUPERSEEDING - if (t->super_seeding() && !m_settings.get_bool(settings_pack::strict_super_seeding)) + if (t->super_seeding() +#if TORRENT_ABI_VERSION == 1 + && !m_settings.get_bool(settings_pack::strict_super_seeding) +#endif + ) { // if we're super-seeding and the peer just told // us that it completed the piece we're super-seeding @@ -2021,6 +2025,7 @@ namespace libtorrent { if (is_disconnecting()) return; #ifndef TORRENT_DISABLE_SUPERSEEDING +#if TORRENT_ABI_VERSION == 1 // if we're super seeding, this might mean that somebody // forwarded this piece. In which case we need to give // a new piece to that peer @@ -2035,7 +2040,8 @@ namespace libtorrent { p->superseed_piece(index, t->get_piece_to_super_seed(p->get_bitfield())); } } -#endif +#endif // TORRENT_ABI_VERSION +#endif // TORRENT_DISABLE_SUPERSEEDING } // ----------------------------- diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 68a909ca5..34af32d73 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -159,7 +159,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0; SET(announce_to_all_trackers, false, nullptr), SET(announce_to_all_tiers, false, nullptr), SET(prefer_udp_trackers, true, nullptr), - SET(strict_super_seeding, false, nullptr), + DEPRECATED_SET(strict_super_seeding, false, nullptr), DEPRECATED_SET(lock_disk_cache, false, nullptr), SET(disable_hash_checks, false, nullptr), SET(allow_i2p_mixed, false, nullptr), diff --git a/src/torrent.cpp b/src/torrent.cpp index 49d8de5e1..fee1402cb 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -10772,7 +10772,9 @@ bool is_downloading_state(int const st) st->is_seeding = is_seed(); st->is_finished = is_finished(); #if TORRENT_ABI_VERSION == 1 +#ifndef TORRENT_DISABLE_SUPERSEEDING st->super_seeding = m_super_seeding; +#endif #endif st->has_metadata = valid_metadata(); bytes_done(*st, flags); diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index e0ac275d0..0c36006b0 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -598,7 +598,13 @@ namespace libtorrent { { return sync_call_ret(false, &torrent::valid_metadata); } bool torrent_handle::super_seeding() const - { return sync_call_ret(false, &torrent::super_seeding); } + { +#ifndef TORRENT_DISABLE_SUPERSEEDING + return sync_call_ret(false, &torrent::super_seeding); +#else + return false; +#endif + } // ============ end deprecation =============== #endif @@ -776,7 +782,10 @@ namespace libtorrent { #if TORRENT_ABI_VERSION == 1 void torrent_handle::super_seeding(bool on) const { + TORRENT_UNUSED(on); +#ifndef TORRENT_DISABLE_SUPERSEEDING async_call(&torrent::set_super_seeding, on); +#endif } void torrent_handle::get_full_peer_list(std::vector& v) const diff --git a/test/swarm_suite.cpp b/test/swarm_suite.cpp index 453cc06f1..e057e1ead 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -78,8 +78,10 @@ void test_swarm(test_flags_t const flags) settings_pack pack = settings(); pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true); +#if TORRENT_ABI_VERSION == 1 if (flags & test_flags::strict_super_seeding) pack.set_bool(settings_pack::strict_super_seeding, true); +#endif if (flags & test_flags::suggest) pack.set_int(settings_pack::suggest_mode, settings_pack::suggest_read_cache);