rate limiter fix
This commit is contained in:
parent
764b5864c6
commit
e2ca3e1545
|
@ -41,6 +41,7 @@
|
|||
incoming connection
|
||||
* added more detailed instrumentation of the disk I/O thread
|
||||
|
||||
* fixed limitation in rate limiter
|
||||
* fixed build error with boost 1.44
|
||||
|
||||
0.15.2 release
|
||||
|
|
|
@ -793,6 +793,7 @@ int main(int argc, char* argv[])
|
|||
" -H Don't start DHT\n"
|
||||
" -W <num peers> Set the max number of peers to keep in the peer list\n"
|
||||
" -N Do not attempt to use UPnP and NAT-PMP to forward ports\n"
|
||||
" -Y Rate limit local peers\n"
|
||||
" "
|
||||
"\n\n"
|
||||
"TORRENT is a path to a .torrent file\n"
|
||||
|
@ -989,6 +990,7 @@ int main(int argc, char* argv[])
|
|||
break;
|
||||
case 'I': outgoing_interface = arg; break;
|
||||
case 'N': start_upnp = false; --i; break;
|
||||
case 'Y': settings.ignore_limits_on_local_network = false; --i; break;
|
||||
}
|
||||
++i; // skip the argument
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_BANDWIDTH_CHANNEL_HPP_INCLUDED
|
||||
|
||||
#include <boost/integer_traits.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
|
@ -70,11 +71,11 @@ private:
|
|||
|
||||
// this is the amount of bandwidth we have
|
||||
// been assigned without using yet.
|
||||
int m_quota_left;
|
||||
boost::int64_t m_quota_left;
|
||||
|
||||
// the limit is the number of bytes
|
||||
// per second we are allowed to use.
|
||||
int m_limit;
|
||||
boost::int64_t m_limit;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace libtorrent
|
|||
int bandwidth_channel::quota_left() const
|
||||
{
|
||||
if (m_limit == 0) return inf;
|
||||
return (std::max)(m_quota_left, 0);
|
||||
return (std::max)(m_quota_left, boost::int64_t(0));
|
||||
}
|
||||
|
||||
void bandwidth_channel::update_quota(int dt_milliseconds)
|
||||
|
@ -60,9 +60,10 @@ namespace libtorrent
|
|||
if (m_limit == 0) return;
|
||||
m_quota_left += (m_limit * dt_milliseconds + 500) / 1000;
|
||||
if (m_quota_left > m_limit * 3) m_quota_left = m_limit * 3;
|
||||
distribute_quota = (std::max)(m_quota_left, 0);
|
||||
// fprintf(stderr, "%p: [%d]: + %d limit: %d\n", this
|
||||
// , dt_milliseconds, (m_limit * dt_milliseconds + 500) / 1000, m_limit);
|
||||
distribute_quota = (std::max)(m_quota_left, boost::int64_t(0));
|
||||
// fprintf(stderr, "%p: [%d]: + %"PRId64" limit: %"PRId64" quota_left: %"PRId64"\n", this
|
||||
// , dt_milliseconds, (m_limit * dt_milliseconds + 500) / 1000, m_limit
|
||||
// , m_quota_left);
|
||||
}
|
||||
|
||||
// this is used when connections disconnect with
|
||||
|
@ -81,6 +82,9 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(amount >= 0);
|
||||
TORRENT_ASSERT(m_limit >= 0);
|
||||
if (m_limit == 0) return;
|
||||
|
||||
// fprintf(stderr, "%p: - %"PRId64" limit: %"PRId64" quota_left: %"PRId64"\n", this
|
||||
// , amount, m_limit, m_quota_left);
|
||||
m_quota_left -= amount;
|
||||
}
|
||||
|
||||
|
|
|
@ -4179,7 +4179,9 @@ namespace libtorrent
|
|||
// peers that we are not interested in are non-prioritized
|
||||
m_channel_state[upload_channel] = peer_info::bw_limit;
|
||||
m_ses.m_upload_rate.request_bandwidth(self()
|
||||
, m_send_buffer.size(), priority
|
||||
, (std::max)(m_send_buffer.size(), m_statistics.upload_rate() * 2
|
||||
/ (1000 / m_ses.m_settings.tick_interval))
|
||||
, priority
|
||||
, bwc1, bwc2, bwc3, bwc4);
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " *** REQUEST_BANDWIDTH [ "
|
||||
|
@ -4212,7 +4214,9 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_outstanding_bytes >= 0);
|
||||
m_channel_state[download_channel] = peer_info::bw_limit;
|
||||
m_ses.m_download_rate.request_bandwidth(self()
|
||||
, (std::max)(m_outstanding_bytes, m_packet_size - m_recv_pos) + 30
|
||||
, (std::max)((std::max)(m_outstanding_bytes, m_packet_size - m_recv_pos) + 30
|
||||
, m_statistics.download_rate() * 2
|
||||
/ (1000 / m_ses.m_settings.tick_interval))
|
||||
, priority , bwc1, bwc2, bwc3, bwc4);
|
||||
}
|
||||
|
||||
|
|
|
@ -1326,7 +1326,7 @@ namespace aux {
|
|||
if (update_disk_io_thread)
|
||||
update_disk_thread_settings();
|
||||
|
||||
if (m_allowed_upload_slots <= m_settings.num_optimistic_unchoke_slots / 2)
|
||||
if (m_settings.num_optimistic_unchoke_slots >= m_allowed_upload_slots / 2)
|
||||
{
|
||||
if (m_alerts.should_post<performance_alert>())
|
||||
m_alerts.post_alert(performance_alert(torrent_handle()
|
||||
|
@ -3697,7 +3697,7 @@ namespace aux {
|
|||
if (m_max_uploads == limit) return;
|
||||
m_max_uploads = limit;
|
||||
m_allowed_upload_slots = limit;
|
||||
if (m_allowed_upload_slots <= m_settings.num_optimistic_unchoke_slots / 2)
|
||||
if (m_settings.num_optimistic_unchoke_slots >= m_allowed_upload_slots / 2)
|
||||
{
|
||||
if (m_alerts.should_post<performance_alert>())
|
||||
m_alerts.post_alert(performance_alert(torrent_handle()
|
||||
|
@ -4063,7 +4063,9 @@ namespace aux {
|
|||
}
|
||||
|
||||
if (m_settings.num_optimistic_unchoke_slots)
|
||||
{
|
||||
TORRENT_ASSERT(num_optimistic <= m_settings.num_optimistic_unchoke_slots);
|
||||
}
|
||||
|
||||
if (m_num_unchoked != unchokes)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue