From 42120014d0b665570697910d0774fbc39e2cb2de Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 28 Apr 2015 04:01:40 +0000 Subject: [PATCH] merged changes from RC_1_0 --- include/libtorrent/extensions.hpp | 9 +++++++-- include/libtorrent/peer_connection.hpp | 6 ++---- src/bt_peer_connection.cpp | 8 +++++++- src/peer_connection.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index d5aa9c25b..6545e228e 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -419,8 +419,13 @@ namespace libtorrent // called when an extended message is received. If returning true, // the message is not processed by any other plugin and if false // is returned the next plugin in the chain will receive it to - // be able to handle it - // this is not called for web seeds + // be able to handle it. This is not called for web seeds. + // thus function may be called more than once per incoming message, but + // only the last of the calls will the ``body`` size equal the ``length``. + // i.e. Every time another fragment of the message is received, this + // function will be called, until finally the whole message has been + // received. The purpose of this is to allow early disconnects for invalid + // messages and for reporting progress of receiving large messages. virtual bool on_extended(int /*length*/, int /*msg*/, buffer::const_interval /*body*/) { return false; } diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index bebfb5e5a..d9948343c 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -698,10 +698,8 @@ namespace libtorrent int send_buffer_capacity() const { return m_send_buffer.capacity(); } - void max_out_request_queue(int s) - { m_max_out_request_queue = s; } - int max_out_request_queue() const - { return m_max_out_request_queue; } + void max_out_request_queue(int s); + int max_out_request_queue() const; #ifdef TORRENT_DEBUG bool piece_failed; diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 17138c477..e63580856 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -1843,7 +1843,13 @@ namespace libtorrent if (!client_info.empty()) m_client_version = client_info; int reqq = int(root.dict_find_int_value("reqq")); - if (reqq > 0) max_out_request_queue(reqq); + if (reqq > 0) + { + max_out_request_queue(reqq); +#ifdef TORRENT_VERBOSE_LOGGING + peer_log("*** MAX OUT REQUEST QUEUE [ %d ]", req); +#endif + } if (root.dict_find_int_value("upload_only", 0)) set_upload_only(true); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 1852d4533..76d882cdc 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4502,6 +4502,20 @@ namespace libtorrent m_superseed_piece[0] = new_piece; } + void peer_connection::max_out_request_queue(int s) + { +#ifdef TORRENT_VERBOSE_LOGGING + peer_log("*** MAX OUT QUEUE SIZE [ %d -> %d ]" + , m_max_out_request_queue, s); +#endif + m_max_out_request_queue = s; + } + + int peer_connection::max_out_request_queue() const + { + return m_max_out_request_queue; + } + void peer_connection::update_desired_queue_size() { TORRENT_ASSERT(is_single_thread()); @@ -4532,6 +4546,12 @@ namespace libtorrent m_desired_queue_size = m_max_out_request_queue; if (m_desired_queue_size < min_request_queue) m_desired_queue_size = min_request_queue; + +#ifdef TORRENT_VERBOSE_LOGGING + peer_log("*** UPDATE_QUEUE_SIZE [ dqs: %d max: %d dl: %d qt: %d snubbed: %d ]" + , m_desired_queue_size, m_max_out_request_queue + , download_rate, queue_time, int(m_snubbed)); +#endif } void peer_connection::second_tick(int tick_interval_ms) @@ -4956,6 +4976,12 @@ namespace libtorrent buffer_size_watermark = m_settings.get_int(settings_pack::send_buffer_watermark); } +#ifdef TORRENT_VERBOSE_LOGGING + peer_log(">>> SEND_BUFFER_WATERMARK [ %d max: %d min: %d factor: %d ]" + , buffer_size_watermark, m_ses.settings().send_buffer_watermark + , m_ses.settings().send_buffer_low_watermark, m_ses.settings().send_buffer_watermark_factor); +#endif + // don't just pop the front element here, since in seed mode one request may // be blocked because we have to verify the hash first, so keep going with the // next request. However, only let each peer have one hash verification outstanding