From efaafea78e6bfeb03a412d31de563deb040dd2dc Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 29 Sep 2011 13:19:08 +0000 Subject: [PATCH] * Bandwidth refiller: Reinitialize at restart, avoid issues from clock skews --- history.txt | 4 ++++ router/java/src/net/i2p/router/Router.java | 1 + router/java/src/net/i2p/router/RouterVersion.java | 4 ++-- .../src/net/i2p/router/transport/FIFOBandwidthLimiter.java | 1 + .../src/net/i2p/router/transport/FIFOBandwidthRefiller.java | 3 +++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/history.txt b/history.txt index b03a2e818..441cc8be9 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,7 @@ +2011-09-29 zzz + * Bandwidth refiller: Reinitialize at restart, avoid + issues from clock skews + 2011-09-27 kytv * Remove exotrack.i2p from i2psnark diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 586a11f83..043f527bc 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -1311,6 +1311,7 @@ public class Router implements RouterClock.ClockShiftListener { // NOTE: DisconnectMessageHandler keys off "restart" try { _context.clientManager().shutdown("Router restart"); } catch (Throwable t) { _log.log(Log.CRIT, "Error stopping the client manager", t); } _log.logAlways(Log.WARN, "Stopping the comm system"); + _context.bandwidthLimiter().reinitialize(); try { _context.messageRegistry().restart(); } catch (Throwable t) { _log.log(Log.CRIT, "Error restarting the message registry", t); } try { _context.commSystem().restart(); } catch (Throwable t) { _log.log(Log.CRIT, "Error restarting the comm system", t); } _log.logAlways(Log.WARN, "Stopping the tunnel manager"); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 43dca9240..a85b0c8aa 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,10 +18,10 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 21; + public final static long BUILD = 22; /** for example "-test" */ - public final static String EXTRA = ""; + public final static String EXTRA = "-rc"; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public static void main(String args[]) { System.out.println("I2P Router version: " + FULL_VERSION); diff --git a/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java b/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java index b8f8a9590..f5aed1edc 100644 --- a/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java +++ b/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java @@ -253,6 +253,7 @@ public class FIFOBandwidthLimiter { // it changes out from under us // This never had locks before concurrent, anyway + // FIXME wrap - change to AtomicLong or detect int avi = _availableInbound.addAndGet((int) bytesInbound); if (avi > _maxInbound) { if (_log.shouldLog(Log.DEBUG)) diff --git a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java index 7dd9d4128..d01374a54 100644 --- a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java +++ b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java @@ -110,6 +110,9 @@ public class FIFOBandwidthRefiller implements Runnable { + " rate in=" + _inboundKBytesPerSecond + ", out=" + _outboundKBytesPerSecond +")"); + // clock skew + if (numMs >= REPLENISH_FREQUENCY * 50 || numMs <= 0) + numMs = REPLENISH_FREQUENCY; if (numMs >= REPLENISH_FREQUENCY) { long inboundToAdd = (1024*_inboundKBytesPerSecond * numMs)/1000; long outboundToAdd = (1024*_outboundKBytesPerSecond * numMs)/1000;