From 85c8e5641750daf9cbd94d85f3d51292cde833f4 Mon Sep 17 00:00:00 2001 From: jrandom <jrandom> Date: Sat, 24 Jul 2004 01:10:11 +0000 Subject: [PATCH] fixed a strange bug when the .wait delay is really accurate (too accurrate..). thanks ZeroCool for help debugging this! --- .../router/transport/FIFOBandwidthRefiller.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java index 15c3cc0e8e..adcf6a14f6 100644 --- a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java +++ b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java @@ -56,9 +56,10 @@ class FIFOBandwidthRefiller implements Runnable { _lastCheckConfigTime = now; } - updateQueues(now); - - _lastRefillTime = now; + boolean updated = updateQueues(now); + if (updated) { + _lastRefillTime = now; + } try { Thread.sleep(_replenishFrequency); } catch (InterruptedException ie) {} } @@ -70,7 +71,7 @@ class FIFOBandwidthRefiller implements Runnable { _lastCheckConfigTime = _lastRefillTime; } - private void updateQueues(long now) { + private boolean updateQueues(long now) { long numMs = (now - _lastRefillTime); if (_log.shouldLog(Log.INFO)) _log.info("Updating bandwidth after " + numMs + " (available in=" @@ -78,7 +79,7 @@ class FIFOBandwidthRefiller implements Runnable { + _limiter.getAvailableOutboundBytes()+ ", rate in=" + _inboundKBytesPerSecond + ", out=" + _outboundKBytesPerSecond +")"); - if (numMs > 1000) { + if (numMs >= 1000) { long inboundToAdd = 1024*_inboundKBytesPerSecond * (numMs/1000); long outboundToAdd = 1024*_outboundKBytesPerSecond * (numMs/1000); @@ -104,6 +105,9 @@ class FIFOBandwidthRefiller implements Runnable { _log.debug("Adding " + inboundToAdd + " bytes to inboundAvailable"); _log.debug("Adding " + outboundToAdd + " bytes to outboundAvailable"); } + return true; + } else { + return false; } } -- GitLab