more tweaks on quota management

This commit is contained in:
Arvid Norberg 2006-11-24 16:59:47 +00:00
parent 955a947863
commit 93b51d7652
2 changed files with 13 additions and 0 deletions

View File

@ -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.

View File

@ -261,6 +261,8 @@ namespace libtorrent
, m_download_bandwidth_limit(std::numeric_limits<int>::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<int>::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;