From f27e24ba98867b990e3432a23124f907f2602c36 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 28 Jul 2010 18:43:56 +0000 Subject: [PATCH] fixed rate limit bug for DHT --- ChangeLog | 1 + src/udp_socket.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ce4e5344e..b077c804a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * fixed rate limit bug for DHT * fixed SOCKS5 bug for routing UDP packets * fixed bug on windows when verifying resume data for a torrent where one of its directories had been removed diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index c4f28bdbe..fa7c0b163 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -772,9 +772,10 @@ void rate_limited_udp_socket::on_tick(error_code const& e) if (m_queue.empty()) return; - while (!m_queue.empty() && int(m_queue.front().buf.size()) >= m_quota) + while (!m_queue.empty() && int(m_queue.front().buf.size()) <= m_quota) { queued_packet const& p = m_queue.front(); + TORRENT_ASSERT(m_quota >= p.buf.size()); m_quota -= p.buf.size(); error_code ec; udp_socket::send(p.ep, &p.buf[0], p.buf.size(), ec);