add build option to disable predictive pieces feature
This commit is contained in:
parent
903ead89b1
commit
0d06d47a29
3
Jamfile
3
Jamfile
|
@ -435,6 +435,9 @@ feature.compose <sanitize>rtc : <cflags>/RTCc <cflags>/RTCsu ;
|
||||||
feature test-coverage : off on : composite propagated link-incompatible ;
|
feature test-coverage : off on : composite propagated link-incompatible ;
|
||||||
feature.compose <test-coverage>on : <cflags>--coverage <linkflags>--coverage ;
|
feature.compose <test-coverage>on : <cflags>--coverage <linkflags>--coverage ;
|
||||||
|
|
||||||
|
feature predictive-pieces : on off : composite propagated ;
|
||||||
|
feature.compose <predictive-pieces>off : <define>TORRENT_DISABLE_PREDICTIVE_PIECES ;
|
||||||
|
|
||||||
feature streaming : on off : composite propagated ;
|
feature streaming : on off : composite propagated ;
|
||||||
feature.compose <streaming>off : <define>TORRENT_DISABLE_STREAMING ;
|
feature.compose <streaming>off : <define>TORRENT_DISABLE_STREAMING ;
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,15 @@ Build features:
|
||||||
| | protocol. |
|
| | protocol. |
|
||||||
| | * ``off`` - disable bittorrent extensions. |
|
| | * ``off`` - disable bittorrent extensions. |
|
||||||
+--------------------------+----------------------------------------------------+
|
+--------------------------+----------------------------------------------------+
|
||||||
|
| ``streaming`` | * ``on`` - enable streaming functionality. i.e. |
|
||||||
|
| | ``set_piece_deadline()``. |
|
||||||
|
| | * ``off`` - disable streaming functionality. |
|
||||||
|
+--------------------------+----------------------------------------------------+
|
||||||
|
| ``predictive-pieces`` | * ``on`` - enable predictive piece announce |
|
||||||
|
| | feature. i.e. |
|
||||||
|
| | settings_pack::predictive_piece_announce |
|
||||||
|
| | * ``off`` - disable feature. |
|
||||||
|
+--------------------------+----------------------------------------------------+
|
||||||
| ``fpic`` | * ``off`` - default. Build without specifying |
|
| ``fpic`` | * ``off`` - default. Build without specifying |
|
||||||
| | ``-fPIC``. |
|
| | ``-fPIC``. |
|
||||||
| | * ``on`` - Force build with ``-fPIC`` (useful for |
|
| | * ``on`` - Force build with ``-fPIC`` (useful for |
|
||||||
|
@ -533,6 +542,10 @@ defines you can use to control the build.
|
||||||
| ``TORRENT_DISABLE_STREAMING`` | Disables set_piece_deadline() and associated |
|
| ``TORRENT_DISABLE_STREAMING`` | Disables set_piece_deadline() and associated |
|
||||||
| | functionality. |
|
| | functionality. |
|
||||||
+----------------------------------------+-------------------------------------------------+
|
+----------------------------------------+-------------------------------------------------+
|
||||||
|
| ``TORRENT_DISABLE_PREDICTIVE_PIECES`` | Disables |
|
||||||
|
| | settings_pack::predictive_piece_announce |
|
||||||
|
| | feature. |
|
||||||
|
+----------------------------------------+-------------------------------------------------+
|
||||||
| ``TORRENT_LINKING_SHARED`` | If this is defined when including the |
|
| ``TORRENT_LINKING_SHARED`` | If this is defined when including the |
|
||||||
| | libtorrent headers, the classes and functions |
|
| | libtorrent headers, the classes and functions |
|
||||||
| | will be tagged with ``__declspec(dllimport)`` |
|
| | will be tagged with ``__declspec(dllimport)`` |
|
||||||
|
|
|
@ -814,6 +814,7 @@ namespace libtorrent {
|
||||||
return m_picker->has_piece_passed(index);
|
return m_picker->has_piece_passed(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
// a predictive piece is a piece that we might
|
// a predictive piece is a piece that we might
|
||||||
// not have yet, but still announced to peers, anticipating that
|
// not have yet, but still announced to peers, anticipating that
|
||||||
// we'll have it very soon
|
// we'll have it very soon
|
||||||
|
@ -821,6 +822,7 @@ namespace libtorrent {
|
||||||
{
|
{
|
||||||
return std::binary_search(m_predictive_pieces.begin(), m_predictive_pieces.end(), index);
|
return std::binary_search(m_predictive_pieces.begin(), m_predictive_pieces.end(), index);
|
||||||
}
|
}
|
||||||
|
#endif // TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -1116,12 +1118,14 @@ namespace libtorrent {
|
||||||
void set_apply_ip_filter(bool b);
|
void set_apply_ip_filter(bool b);
|
||||||
bool apply_ip_filter() const { return m_apply_ip_filter; }
|
bool apply_ip_filter() const { return m_apply_ip_filter; }
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
std::vector<piece_index_t> const& predictive_pieces() const
|
std::vector<piece_index_t> const& predictive_pieces() const
|
||||||
{ return m_predictive_pieces; }
|
{ return m_predictive_pieces; }
|
||||||
|
|
||||||
// this is called whenever we predict to have this piece
|
// this is called whenever we predict to have this piece
|
||||||
// within one second
|
// within one second
|
||||||
void predicted_have_piece(piece_index_t index, int milliseconds);
|
void predicted_have_piece(piece_index_t index, int milliseconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
void clear_in_state_update()
|
void clear_in_state_update()
|
||||||
{
|
{
|
||||||
|
@ -1336,6 +1340,7 @@ namespace libtorrent {
|
||||||
std::string m_source_feed_url;
|
std::string m_source_feed_url;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
// this is a list of all pieces that we have announced
|
// this is a list of all pieces that we have announced
|
||||||
// as having, without actually having yet. If we receive
|
// as having, without actually having yet. If we receive
|
||||||
// a request for a piece in this list, we need to hold off
|
// a request for a piece in this list, we need to hold off
|
||||||
|
@ -1347,6 +1352,7 @@ namespace libtorrent {
|
||||||
// TODO: 3 factor out predictive pieces and all operations on it into a
|
// TODO: 3 factor out predictive pieces and all operations on it into a
|
||||||
// separate class (to use as memeber here instead)
|
// separate class (to use as memeber here instead)
|
||||||
std::vector<piece_index_t> m_predictive_pieces;
|
std::vector<piece_index_t> m_predictive_pieces;
|
||||||
|
#endif
|
||||||
|
|
||||||
// the performance counters of this session
|
// the performance counters of this session
|
||||||
counters& m_stats_counters;
|
counters& m_stats_counters;
|
||||||
|
|
|
@ -2045,10 +2045,12 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
// 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
|
||||||
for (piece_index_t const p : t->predictive_pieces())
|
for (piece_index_t const p : t->predictive_pieces())
|
||||||
msg[5 + static_cast<int>(p) / CHAR_BIT] |= (char_top_bit >> (static_cast<int>(p) & char_bit_mask));
|
msg[5 + static_cast<int>(p) / CHAR_BIT] |= (char_top_bit >> (static_cast<int>(p) & char_bit_mask));
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (should_log(peer_log_alert::outgoing_message))
|
if (should_log(peer_log_alert::outgoing_message))
|
||||||
|
|
|
@ -2430,7 +2430,9 @@ namespace libtorrent {
|
||||||
if (r.piece < piece_index_t(0)
|
if (r.piece < piece_index_t(0)
|
||||||
|| r.piece >= t->torrent_file().end_piece()
|
|| r.piece >= t->torrent_file().end_piece()
|
||||||
|| (!t->has_piece_passed(r.piece)
|
|| (!t->has_piece_passed(r.piece)
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
&& !t->is_predictive_piece(r.piece)
|
&& !t->is_predictive_piece(r.piece)
|
||||||
|
#endif
|
||||||
&& !t->seed_mode())
|
&& !t->seed_mode())
|
||||||
|| r.start < 0
|
|| r.start < 0
|
||||||
|| r.start >= ti.piece_size(r.piece)
|
|| r.start >= ti.piece_size(r.piece)
|
||||||
|
@ -2959,6 +2961,7 @@ namespace libtorrent {
|
||||||
// if we requested this block from other peers, cancel it now
|
// if we requested this block from other peers, cancel it now
|
||||||
if (multi) t->cancel_block(block_finished);
|
if (multi) t->cancel_block(block_finished);
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
if (m_settings.get_int(settings_pack::predictive_piece_announce))
|
if (m_settings.get_int(settings_pack::predictive_piece_announce))
|
||||||
{
|
{
|
||||||
piece_index_t const piece = block_finished.piece_index;
|
piece_index_t const piece = block_finished.piece_index;
|
||||||
|
@ -2994,6 +2997,7 @@ namespace libtorrent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
|
|
||||||
TORRENT_ASSERT(picker.num_peers(block_finished) == 0);
|
TORRENT_ASSERT(picker.num_peers(block_finished) == 0);
|
||||||
|
|
||||||
|
@ -5208,11 +5212,13 @@ namespace libtorrent {
|
||||||
|
|
||||||
if (!t->has_piece_passed(r.piece) && !seed_mode)
|
if (!t->has_piece_passed(r.piece) && !seed_mode)
|
||||||
{
|
{
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
// we don't have this piece yet, but we anticipate to have
|
// we don't have this piece yet, but we anticipate to have
|
||||||
// it very soon, so we have told our peers we have it.
|
// it very soon, so we have told our peers we have it.
|
||||||
// hold off on sending it. If the piece fails later
|
// hold off on sending it. If the piece fails later
|
||||||
// we will reject this request
|
// we will reject this request
|
||||||
if (t->is_predictive_piece(r.piece)) continue;
|
if (t->is_predictive_piece(r.piece)) continue;
|
||||||
|
#endif
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::outgoing_message, "REJECT_PIECE"
|
peer_log(peer_log_alert::outgoing_message, "REJECT_PIECE"
|
||||||
, "piece: %d s: %x l: %x piece not passed hash check"
|
, "piece: %d s: %x l: %x piece not passed hash check"
|
||||||
|
|
|
@ -3862,6 +3862,7 @@ bool is_downloading_state(int const st)
|
||||||
// (unless it has already been announced through predictive_piece_announce
|
// (unless it has already been announced through predictive_piece_announce
|
||||||
// feature).
|
// feature).
|
||||||
bool announce_piece = true;
|
bool announce_piece = true;
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
auto const it = std::lower_bound(m_predictive_pieces.begin()
|
auto const it = std::lower_bound(m_predictive_pieces.begin()
|
||||||
, m_predictive_pieces.end(), index);
|
, m_predictive_pieces.end(), index);
|
||||||
if (it != m_predictive_pieces.end() && *it == index)
|
if (it != m_predictive_pieces.end() && *it == index)
|
||||||
|
@ -3870,6 +3871,7 @@ bool is_downloading_state(int const st)
|
||||||
announce_piece = false;
|
announce_piece = false;
|
||||||
m_predictive_pieces.erase(it);
|
m_predictive_pieces.erase(it);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// make a copy of the peer list since peers
|
// make a copy of the peer list since peers
|
||||||
// may disconnect while looping
|
// may disconnect while looping
|
||||||
|
@ -4043,6 +4045,7 @@ bool is_downloading_state(int const st)
|
||||||
we_have(index);
|
we_have(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
// we believe we will complete this piece very soon
|
// we believe we will complete this piece very soon
|
||||||
// announce it to peers ahead of time to eliminate the
|
// announce it to peers ahead of time to eliminate the
|
||||||
// round-trip times involved in announcing it, requesting it
|
// round-trip times involved in announcing it, requesting it
|
||||||
|
@ -4068,6 +4071,7 @@ bool is_downloading_state(int const st)
|
||||||
|
|
||||||
m_predictive_pieces.insert(i, index);
|
m_predictive_pieces.insert(i, index);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void torrent::piece_failed(piece_index_t const index)
|
void torrent::piece_failed(piece_index_t const index)
|
||||||
{
|
{
|
||||||
|
@ -4085,6 +4089,7 @@ bool is_downloading_state(int const st)
|
||||||
|
|
||||||
inc_stats_counter(counters::num_piece_failed);
|
inc_stats_counter(counters::num_piece_failed);
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_PREDICTIVE_PIECES
|
||||||
auto const it = std::lower_bound(m_predictive_pieces.begin()
|
auto const it = std::lower_bound(m_predictive_pieces.begin()
|
||||||
, m_predictive_pieces.end(), index);
|
, m_predictive_pieces.end(), index);
|
||||||
if (it != m_predictive_pieces.end() && *it == index)
|
if (it != m_predictive_pieces.end() && *it == index)
|
||||||
|
@ -4101,6 +4106,7 @@ bool is_downloading_state(int const st)
|
||||||
}
|
}
|
||||||
m_predictive_pieces.erase(it);
|
m_predictive_pieces.erase(it);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// increase the total amount of failed bytes
|
// increase the total amount of failed bytes
|
||||||
add_failed_bytes(m_torrent_file->piece_size(index));
|
add_failed_bytes(m_torrent_file->piece_size(index));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue