diff --git a/ChangeLog b/ChangeLog index 6afa76f11..50d322a40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -90,6 +90,7 @@ * only keeps one outstanding duplicate request per peer reduces waste download, specifically when streaming + * disabled feature to drop requests after having been skipped too many times * fixed range request bug for files larger than 2 GB in web seeds release 0.14.8 diff --git a/docs/manual.rst b/docs/manual.rst index 6c1ab759e..2a1461301 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -3711,6 +3711,8 @@ session_settings bool disable_hash_check; int max_suggest_pieces; + + bool drop_skipped_requests; }; ``user_agent`` this is the client identification to the tracker. @@ -4140,6 +4142,16 @@ bittorrent clients. from a peer that's remembered. If a peer floods suggest messages, this limit prevents libtorrent from using too much RAM. It defaults to 10. +If ``drop_skipped_requests`` is set to true (it defaults to false), piece +requests that have been skipped enough times when piece messages +are received, will be considered lost. Requests are considered skipped +when the returned piece messages are re-ordered compared to the order +of the requests. This was an attempt to get out of dead-locks caused by +BitComet peers silently ignoring some requests. It may cause problems +at high rates, and high level of reordering in the uploading peer, that's +why it's disabled by default. + + pe_settings =========== diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 50c844258..de391d2bc 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -181,6 +181,7 @@ namespace libtorrent , allow_reordered_disk_operations(true) , allow_i2p_mixed(false) , max_suggest_pieces(10) + , drop_skipped_requests(false) {} // this is the user agent that will be sent to the tracker @@ -650,6 +651,11 @@ namespace libtorrent // suggest to use before we start dropping // previous suggested piece int max_suggest_pieces; + + // if set to true, requests that have have not been + // satisfied after the equivalence of the entire + // request queue has been received, will be considered lost + bool drop_skipped_requests; }; #ifndef TORRENT_DISABLE_DHT diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 3ebf25b56..55a6bb444 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2153,19 +2153,28 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING (*m_logger) << time_now_string() << " *** SKIPPED_PIECE [ piece: " << qe.block.piece_index << " | " - "b: " << qe.block.block_index << " ] ***\n"; + "b: " << qe.block.block_index << " | skip: " << qe.skipped << " | " + "dqs: " << int(m_desired_queue_size) << "] ***\n"; #endif ++qe.skipped; // if the number of times a block is skipped by out of order // blocks exceeds the size of the outstanding queue, assume that // the other end dropped the request. - if (qe.skipped > m_desired_queue_size * 2) + if (m_ses.m_settings.drop_skipped_requests + && qe.skipped > m_desired_queue_size) + if (qe.skipped > m_desired_queue_size) { if (m_ses.m_alerts.should_post()) m_ses.m_alerts.post_alert(request_dropped_alert(t->get_handle() , remote(), pid(), qe.block.block_index, qe.block.piece_index)); +#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING + (*m_logger) << time_now_string() + << " *** DROPPED_PIECE [ piece: " << qe.block.piece_index << " | " + "b: " << qe.block.block_index << " | skip: " << qe.skipped << " | " + "dqs: " << int(m_desired_queue_size) << "] ***\n"; +#endif if (!qe.timed_out && !qe.not_wanted) picker.abort_download(qe.block); @@ -2998,7 +3007,8 @@ namespace libtorrent "s: " << r.start << " | " "l: " << r.length << " | " "ds: " << statistics().download_rate() << " B/s | " - "qs: " << int(m_desired_queue_size) << " " + "dqs: " << int(m_desired_queue_size) << " " + "rqs: " << int(m_download_queue.size()) << " " "blk: " << (m_request_large_blocks?"large":"single") << " ]\n"; #endif }