remove lazy_bitfield (#817)

remove lazy_bitfield feature
This commit is contained in:
Arvid Norberg 2016-06-19 17:00:18 -04:00 committed by GitHub
parent 15bac1e9b5
commit b2358666a1
5 changed files with 17 additions and 56 deletions

View File

@ -1,3 +1,4 @@
* remove lazy-bitfield feature
* simplified suggest-read-cache feature to not depend on disk threads
* removed option to disable contiguous receive buffers
* deprecated public to_hex() and from_hex() functions

View File

@ -234,11 +234,15 @@ namespace libtorrent
// Default is false.
send_redundant_have,
#ifndef TORRENT_NO_DEPRECATE
// if this is true, outgoing bitfields will never be fuil. If the
// client is seed, a few bits will be set to 0, and later filled in
// with have messages. This is to prevent certain ISPs from stopping
// people from seeding.
lazy_bitfields,
#else
deprecated12,
#endif
// ``use_dht_as_fallback`` determines how the DHT is used. If this is
// true, the DHT will only be used for torrents where all trackers in

View File

@ -2113,7 +2113,7 @@ namespace libtorrent
if (piece >= 0) superseed_piece(-1, piece);
return;
}
else if (m_supports_fast && t->is_seed() && !m_settings.get_bool(settings_pack::lazy_bitfields))
else if (m_supports_fast && t->is_seed())
{
write_have_all();
return;
@ -2136,26 +2136,6 @@ namespace libtorrent
const int num_pieces = t->torrent_file().num_pieces();
TORRENT_ASSERT(num_pieces > 0);
int lazy_pieces[50];
int num_lazy_pieces = 0;
int lazy_piece = 0;
if (t->is_seed() && m_settings.get_bool(settings_pack::lazy_bitfields)
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
&& !m_encrypted
#endif
)
{
num_lazy_pieces = (std::min)(50, num_pieces / 10);
if (num_lazy_pieces < 1) num_lazy_pieces = 1;
for (int i = 0; i < num_pieces; ++i)
{
if (int(random() % (num_pieces - i)) >= num_lazy_pieces - lazy_piece) continue;
lazy_pieces[lazy_piece++] = i;
}
TORRENT_ASSERT(lazy_piece == num_lazy_pieces);
}
const int packet_size = (num_pieces + 7) / 8 + 5;
std::uint8_t* msg = TORRENT_ALLOCA(std::uint8_t, packet_size);
@ -2189,8 +2169,6 @@ namespace libtorrent
}
}
}
for (int c = 0; c < num_lazy_pieces; ++c)
msg[5 + lazy_pieces[c] / 8] &= ~(0x80 >> (lazy_pieces[c] & 7));
// add predictive pieces to the bitfield as well, since we won't
// announce them again
@ -2199,7 +2177,6 @@ namespace libtorrent
msg[5 + *i / 8] |= (0x80 >> (*i & 7));
#ifndef TORRENT_DISABLE_LOGGING
std::string bitfield_string;
bitfield_string.resize(num_pieces);
for (int k = 0; k < num_pieces; ++k)
@ -2215,19 +2192,6 @@ namespace libtorrent
send_buffer(reinterpret_cast<char const*>(msg), packet_size);
stats_counters().inc_stats_counter(counters::num_outgoing_bitfield);
if (num_lazy_pieces > 0)
{
for (int i = 0; i < num_lazy_pieces; ++i)
{
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::outgoing_message, "HAVE"
, "piece: %d", lazy_pieces[i]);
#endif
write_have(lazy_pieces[i]);
}
// TODO: if we're finished, send upload_only message
}
}
#ifndef TORRENT_DISABLE_EXTENSIONS
@ -2277,24 +2241,19 @@ namespace libtorrent
if (t->last_seen_complete() > 0) complete_ago = t->time_since_complete();
handshake["complete_ago"] = complete_ago;
// if we're using lazy bitfields or if we're super seeding, don't say
// we're upload only, since it might make peers disconnect. don't tell
// anyone we're upload only when in share mode, we want to stay connected
// to seeds. if we're super seeding, we don't want to make peers think
// that we only have a single piece and is upload only, since they might
// disconnect immediately when they have downloaded a single piece,
// although we'll make another piece available. If we don't have
// metadata, we also need to suppress saying we're upload-only. If we do,
// we may be disconnected before we receive the metadata.
// if we're super seeding, don't say we're upload only, since it might
// make peers disconnect. don't tell anyone we're upload only when in
// share mode, we want to stay connected to seeds. if we're super seeding,
// we don't want to make peers think that we only have a single piece and
// is upload only, since they might disconnect immediately when they have
// downloaded a single piece, although we'll make another piece available.
// If we don't have metadata, we also need to suppress saying we're
// upload-only. If we do, we may be disconnected before we receive the
// metadata.
if (t->is_upload_only()
&& !t->share_mode()
&& t->valid_metadata()
&& !t->super_seeding()
&& (!m_settings.get_bool(settings_pack::lazy_bitfields)
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|| m_encrypted
#endif
))
&& !t->super_seeding())
{
handshake["upload_only"] = 1;
}

View File

@ -149,7 +149,7 @@ namespace libtorrent
SET(allow_multiple_connections_per_ip, false, 0),
DEPRECATED_SET(ignore_limits_on_local_network, true, &session_impl::update_ignore_rate_limits_on_local_network),
SET(send_redundant_have, true, 0),
SET(lazy_bitfields, false, 0),
DEPRECATED_SET(lazy_bitfields, false, 0),
SET(use_dht_as_fallback, false, 0),
SET(upnp_ignore_nonrouters, false, 0),
SET(use_parole_mode, true, 0),

View File

@ -87,7 +87,6 @@ TORRENT_TEST(sparse_pack)
TEST_EQUAL(pack.has_val(settings_pack::send_redundant_have), true);
TEST_EQUAL(pack.has_val(settings_pack::user_agent), false);
TEST_EQUAL(pack.has_val(settings_pack::lazy_bitfields), false);
TEST_EQUAL(pack.get_bool(settings_pack::send_redundant_have), true);
}
@ -124,14 +123,12 @@ TORRENT_TEST(clear)
TEST_EQUAL(pack.has_val(settings_pack::send_redundant_have), true);
TEST_EQUAL(pack.has_val(settings_pack::user_agent), false);
TEST_EQUAL(pack.has_val(settings_pack::lazy_bitfields), false);
TEST_EQUAL(pack.get_bool(settings_pack::send_redundant_have), true);
pack.clear();
TEST_EQUAL(pack.has_val(settings_pack::send_redundant_have), false);
TEST_EQUAL(pack.has_val(settings_pack::user_agent), false);
TEST_EQUAL(pack.has_val(settings_pack::lazy_bitfields), false);
}
TORRENT_TEST(duplicates)