|
|
@ -1191,13 +1191,18 @@ void Session::processBannedIPs(lt::ip_filter &filter) |
|
|
|
void Session::adjustLimits(lt::settings_pack &settingsPack) const |
|
|
|
void Session::adjustLimits(lt::settings_pack &settingsPack) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Internally increase the queue limits to ensure that the magnet is started
|
|
|
|
// Internally increase the queue limits to ensure that the magnet is started
|
|
|
|
const int maxDownloads = maxActiveDownloads(); |
|
|
|
const auto adjustLimit = [this](const int limit) -> int |
|
|
|
const int maxActive = maxActiveTorrents(); |
|
|
|
{ |
|
|
|
|
|
|
|
if (limit <= -1) |
|
|
|
|
|
|
|
return limit; |
|
|
|
|
|
|
|
// check for overflow: (limit + m_extraLimit) < std::numeric_limits<int>::max()
|
|
|
|
|
|
|
|
return (m_extraLimit < (std::numeric_limits<int>::max() - limit)) |
|
|
|
|
|
|
|
? (limit + m_extraLimit) |
|
|
|
|
|
|
|
: std::numeric_limits<int>::max(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
settingsPack.set_int(lt::settings_pack::active_downloads |
|
|
|
settingsPack.set_int(lt::settings_pack::active_downloads, adjustLimit(maxActiveDownloads())); |
|
|
|
, maxDownloads > -1 ? maxDownloads + m_extraLimit : maxDownloads); |
|
|
|
settingsPack.set_int(lt::settings_pack::active_limit, adjustLimit(maxActiveTorrents())); |
|
|
|
settingsPack.set_int(lt::settings_pack::active_limit |
|
|
|
|
|
|
|
, maxActive > -1 ? maxActive + m_extraLimit : maxActive); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Session::applyBandwidthLimits(lt::settings_pack &settingsPack) const |
|
|
|
void Session::applyBandwidthLimits(lt::settings_pack &settingsPack) const |
|
|
|