From 90e82152b07a74b74c10562a1d20cc61cda6b785 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 11 May 2018 23:56:04 +0200 Subject: [PATCH 1/2] back-port fixes to Jamfile from master --- Jamfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jamfile b/Jamfile index 9d558b2bd..41090d318 100644 --- a/Jamfile +++ b/Jamfile @@ -796,11 +796,11 @@ local usage-requirements = BOOST_ASIO_ENABLE_CANCELIO @linking # these compiler settings just makes the compiler standard conforming - msvc:/Zc:wchar_t - msvc:/Zc:forScope + msvc:"/Zc:wchar_t" + msvc:"/Zc:forScope" # msvc optimizations - msvc,release:/OPT:ICF=5 - msvc,release:/OPT:REF + msvc,release:"/OPT:ICF=5" + msvc,release:"/OPT:REF" $(CXXFLAGS) $(LDFLAGS) From f052d1ca404c658de1c9c20e6929f932f1883a73 Mon Sep 17 00:00:00 2001 From: d-komarov Date: Sat, 12 May 2018 14:53:03 +0300 Subject: [PATCH 2/2] Fix bandwidth allocation (#2810) Don't allow peer connection to ask quota from bandwidth manager if send buffer is empty. Remove undefined member function Update download rate multiplier --- include/libtorrent/peer_connection.hpp | 5 ----- src/peer_connection.cpp | 18 ++++++++---------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index d2997c428..38aa7553f 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -501,11 +501,6 @@ namespace libtorrent // finish the connection attempt bool is_connecting() const { return m_connecting; } - // This is called for every peer right after the upload - // bandwidth has been distributed among them - // It will reset the used bandwidth to 0. - void reset_upload_quota(); - // trust management. virtual void received_valid_data(int index); // returns false if the peer should not be diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 14961345e..1427c47da 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5457,23 +5457,20 @@ namespace libtorrent int peer_connection::wanted_transfer(int channel) { TORRENT_ASSERT(is_single_thread()); - shared_ptr t = m_torrent.lock(); const int tick_interval = (std::max)(1, m_settings.get_int(settings_pack::tick_interval)); if (channel == download_channel) { - return std::max((std::max)(m_outstanding_bytes - , m_recv_buffer.packet_bytes_remaining()) + 30 - , int(boost::int64_t(m_statistics.download_rate()) * 2 - * tick_interval / 1000)); + boost::int64_t const download_rate = boost::int64_t(m_statistics.download_rate()) * 3 / 2; + return std::max(int(download_rate * tick_interval / 1000), + (std::max)(m_outstanding_bytes, m_recv_buffer.packet_bytes_remaining()) + 30); } else { - return std::max((std::max)(m_reading_bytes - , m_send_buffer.size()) - , int((boost::int64_t(m_statistics.upload_rate()) * 2 - * tick_interval) / 1000)); + boost::int64_t const upload_rate = boost::int64_t(m_statistics.upload_rate()) * 2; + return std::max(int(upload_rate * tick_interval / 1000), + (std::max)(m_reading_bytes, m_send_buffer.size())); } } @@ -5559,7 +5556,8 @@ namespace libtorrent void peer_connection::setup_send() { TORRENT_ASSERT(is_single_thread()); - if (m_disconnecting) return; + + if (m_disconnecting || m_send_buffer.empty()) return; // we may want to request more quota at this point request_bandwidth(upload_channel);