From f1102f0b4d34de9ebaa04852c4f9882f549317cc Mon Sep 17 00:00:00 2001 From: Yat Ho Date: Thu, 7 Nov 2024 03:55:58 +0800 Subject: [PATCH] fix: don't double count webseed download data rate (#7235) Regression from f1a53840f924c7bb4194ab6971c1a2d57f525ade --- libtransmission/session.cc | 10 ---------- libtransmission/session.h | 1 - libtransmission/web.cc | 2 -- libtransmission/web.h | 5 ----- 4 files changed, 18 deletions(-) diff --git a/libtransmission/session.cc b/libtransmission/session.cc index 2bd1f22ac..a386b5afc 100644 --- a/libtransmission/session.cc +++ b/libtransmission/session.cc @@ -341,16 +341,6 @@ size_t tr_session::WebMediator::clamp(int torrent_id, size_t byte_count) const return tor == nullptr ? 0U : tor->bandwidth().clamp(TR_DOWN, byte_count); } -void tr_session::WebMediator::notifyBandwidthConsumed(int torrent_id, size_t byte_count) -{ - auto const lock = session_->unique_lock(); - - if (auto* const tor = session_->torrents().get(torrent_id); tor != nullptr) - { - tor->bandwidth().notify_bandwidth_consumed(TR_DOWN, byte_count, true, tr_time_msec()); - } -} - void tr_session::WebMediator::run(tr_web::FetchDoneFunc&& func, tr_web::FetchResponse&& response) const { session_->run_in_session_thread(std::move(func), std::move(response)); diff --git a/libtransmission/session.h b/libtransmission/session.h index 662f1b5e8..f0a29ed9c 100644 --- a/libtransmission/session.h +++ b/libtransmission/session.h @@ -244,7 +244,6 @@ private: [[nodiscard]] std::optional userAgent() const override; [[nodiscard]] size_t clamp(int torrent_id, size_t byte_count) const override; [[nodiscard]] time_t now() const override; - void notifyBandwidthConsumed(int torrent_id, size_t byte_count) override; // runs the tr_web::fetch response callback in the libtransmission thread void run(tr_web::FetchDoneFunc&& func, tr_web::FetchResponse&& response) const override; diff --git a/libtransmission/web.cc b/libtransmission/web.cc index 628f72b83..9354cc44e 100644 --- a/libtransmission/web.cc +++ b/libtransmission/web.cc @@ -482,8 +482,6 @@ public: task->impl.paused_easy_handles.emplace(task->easy(), tr_time_msec()); return CURL_WRITEFUNC_PAUSE; } - - task->impl.mediator.notifyBandwidthConsumed(*tag, bytes_used); } evbuffer_add(task->body(), data, bytes_used); diff --git a/libtransmission/web.h b/libtransmission/web.h index c034abd1e..13a18f35a 100644 --- a/libtransmission/web.h +++ b/libtransmission/web.h @@ -143,11 +143,6 @@ public: return std::nullopt; } - // Notify the system that `byte_count` of download bandwidth was used - virtual void notifyBandwidthConsumed([[maybe_unused]] int bandwidth_tag, [[maybe_unused]] size_t byte_count) - { - } - // Return the number of bytes that should be allowed. See tr_bandwidth::clamp() [[nodiscard]] virtual size_t clamp([[maybe_unused]] int bandwidth_tag, size_t byte_count) const {