forked from premiere/premiere-libtorrent
parent
15bac1e9b5
commit
b2358666a1
|
@ -1,3 +1,4 @@
|
||||||
|
* remove lazy-bitfield feature
|
||||||
* simplified suggest-read-cache feature to not depend on disk threads
|
* simplified suggest-read-cache feature to not depend on disk threads
|
||||||
* removed option to disable contiguous receive buffers
|
* removed option to disable contiguous receive buffers
|
||||||
* deprecated public to_hex() and from_hex() functions
|
* deprecated public to_hex() and from_hex() functions
|
||||||
|
|
|
@ -234,11 +234,15 @@ namespace libtorrent
|
||||||
// Default is false.
|
// Default is false.
|
||||||
send_redundant_have,
|
send_redundant_have,
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// if this is true, outgoing bitfields will never be fuil. If the
|
// 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
|
// 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
|
// with have messages. This is to prevent certain ISPs from stopping
|
||||||
// people from seeding.
|
// people from seeding.
|
||||||
lazy_bitfields,
|
lazy_bitfields,
|
||||||
|
#else
|
||||||
|
deprecated12,
|
||||||
|
#endif
|
||||||
|
|
||||||
// ``use_dht_as_fallback`` determines how the DHT is used. If this is
|
// ``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
|
// true, the DHT will only be used for torrents where all trackers in
|
||||||
|
|
|
@ -2113,7 +2113,7 @@ namespace libtorrent
|
||||||
if (piece >= 0) superseed_piece(-1, piece);
|
if (piece >= 0) superseed_piece(-1, piece);
|
||||||
return;
|
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();
|
write_have_all();
|
||||||
return;
|
return;
|
||||||
|
@ -2136,26 +2136,6 @@ namespace libtorrent
|
||||||
const int num_pieces = t->torrent_file().num_pieces();
|
const int num_pieces = t->torrent_file().num_pieces();
|
||||||
TORRENT_ASSERT(num_pieces > 0);
|
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;
|
const int packet_size = (num_pieces + 7) / 8 + 5;
|
||||||
|
|
||||||
std::uint8_t* msg = TORRENT_ALLOCA(std::uint8_t, packet_size);
|
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
|
// add predictive pieces to the bitfield as well, since we won't
|
||||||
// announce them again
|
// announce them again
|
||||||
|
@ -2199,7 +2177,6 @@ namespace libtorrent
|
||||||
msg[5 + *i / 8] |= (0x80 >> (*i & 7));
|
msg[5 + *i / 8] |= (0x80 >> (*i & 7));
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
|
||||||
std::string bitfield_string;
|
std::string bitfield_string;
|
||||||
bitfield_string.resize(num_pieces);
|
bitfield_string.resize(num_pieces);
|
||||||
for (int k = 0; k < num_pieces; ++k)
|
for (int k = 0; k < num_pieces; ++k)
|
||||||
|
@ -2215,19 +2192,6 @@ namespace libtorrent
|
||||||
send_buffer(reinterpret_cast<char const*>(msg), packet_size);
|
send_buffer(reinterpret_cast<char const*>(msg), packet_size);
|
||||||
|
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_bitfield);
|
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
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
@ -2277,24 +2241,19 @@ namespace libtorrent
|
||||||
if (t->last_seen_complete() > 0) complete_ago = t->time_since_complete();
|
if (t->last_seen_complete() > 0) complete_ago = t->time_since_complete();
|
||||||
handshake["complete_ago"] = complete_ago;
|
handshake["complete_ago"] = complete_ago;
|
||||||
|
|
||||||
// if we're using lazy bitfields or if we're super seeding, don't say
|
// if we're super seeding, don't say we're upload only, since it might
|
||||||
// we're upload only, since it might make peers disconnect. don't tell
|
// make peers disconnect. don't tell anyone we're upload only when in
|
||||||
// anyone we're upload only when in share mode, we want to stay connected
|
// share mode, we want to stay connected to seeds. if we're super seeding,
|
||||||
// to seeds. if we're super seeding, we don't want to make peers think
|
// we don't want to make peers think that we only have a single piece and
|
||||||
// that we only have a single piece and is upload only, since they might
|
// is upload only, since they might disconnect immediately when they have
|
||||||
// disconnect immediately when they have downloaded a single piece,
|
// downloaded a single piece, although we'll make another piece available.
|
||||||
// although we'll make another piece available. If we don't have
|
// If we don't have metadata, we also need to suppress saying we're
|
||||||
// metadata, we also need to suppress saying we're upload-only. If we do,
|
// upload-only. If we do, we may be disconnected before we receive the
|
||||||
// we may be disconnected before we receive the metadata.
|
// metadata.
|
||||||
if (t->is_upload_only()
|
if (t->is_upload_only()
|
||||||
&& !t->share_mode()
|
&& !t->share_mode()
|
||||||
&& t->valid_metadata()
|
&& t->valid_metadata()
|
||||||
&& !t->super_seeding()
|
&& !t->super_seeding())
|
||||||
&& (!m_settings.get_bool(settings_pack::lazy_bitfields)
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
|
||||||
|| m_encrypted
|
|
||||||
#endif
|
|
||||||
))
|
|
||||||
{
|
{
|
||||||
handshake["upload_only"] = 1;
|
handshake["upload_only"] = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace libtorrent
|
||||||
SET(allow_multiple_connections_per_ip, false, 0),
|
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),
|
DEPRECATED_SET(ignore_limits_on_local_network, true, &session_impl::update_ignore_rate_limits_on_local_network),
|
||||||
SET(send_redundant_have, true, 0),
|
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(use_dht_as_fallback, false, 0),
|
||||||
SET(upnp_ignore_nonrouters, false, 0),
|
SET(upnp_ignore_nonrouters, false, 0),
|
||||||
SET(use_parole_mode, true, 0),
|
SET(use_parole_mode, true, 0),
|
||||||
|
|
|
@ -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::send_redundant_have), true);
|
||||||
TEST_EQUAL(pack.has_val(settings_pack::user_agent), false);
|
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);
|
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::send_redundant_have), true);
|
||||||
TEST_EQUAL(pack.has_val(settings_pack::user_agent), false);
|
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);
|
TEST_EQUAL(pack.get_bool(settings_pack::send_redundant_have), true);
|
||||||
|
|
||||||
pack.clear();
|
pack.clear();
|
||||||
|
|
||||||
TEST_EQUAL(pack.has_val(settings_pack::send_redundant_have), false);
|
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::user_agent), false);
|
||||||
TEST_EQUAL(pack.has_val(settings_pack::lazy_bitfields), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_TEST(duplicates)
|
TORRENT_TEST(duplicates)
|
||||||
|
|
Loading…
Reference in New Issue