From 93b51d7652d55247e91565118f445f72eb333c0b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 24 Nov 2006 16:59:47 +0000 Subject: [PATCH] more tweaks on quota management --- include/libtorrent/torrent.hpp | 3 +++ src/torrent.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index a3e686b98..b826ff5e6 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -576,6 +576,9 @@ namespace libtorrent int m_excess_ul; int m_excess_dl; + int m_soft_ul_limit; + int m_soft_dl_limit; + boost::filesystem::path m_save_path; // determines the storage state for this torrent. diff --git a/src/torrent.cpp b/src/torrent.cpp index d3785bdc3..3577b6c91 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -261,6 +261,8 @@ namespace libtorrent , m_download_bandwidth_limit(std::numeric_limits::max()) , m_excess_ul(0) , m_excess_dl(0) + , m_soft_ul_limit(10000) + , m_soft_dl_limit(10000) , m_save_path(complete(save_path)) , m_compact_mode(compact_mode) , m_default_block_size(block_size) @@ -375,6 +377,8 @@ namespace libtorrent , m_download_bandwidth_limit(std::numeric_limits::max()) , m_excess_ul(0) , m_excess_dl(0) + , m_soft_ul_limit(10000) + , m_soft_dl_limit(10000) , m_save_path(complete(save_path)) , m_compact_mode(compact_mode) , m_default_block_size(block_size) @@ -1917,6 +1921,12 @@ namespace libtorrent int dl_to_distribute = std::max(int((m_dl_bandwidth_quota.given - m_excess_dl * 0.7f) * 1.6f), 0); + m_soft_ul_limit = m_soft_ul_limit + (ul_to_distribute - m_soft_ul_limit) * 0.1f; + m_soft_dl_limit = m_soft_dl_limit + (dl_to_distribute - m_soft_dl_limit) * 0.1f; + + ul_to_distribute = m_soft_ul_limit; + dl_to_distribute = m_soft_dl_limit; + #ifdef TORRENT_LOGGING std::copy(m_ul_history + 1, m_ul_history + debug_bw_history_size, m_ul_history); m_ul_history[debug_bw_history_size-1] = ul_used;