diff --git a/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java b/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java index 9d3588c2d1f9ad9de663990b7f6d91ff4dbc321a..e2a6561afe9998cced9aa7fff80a0357ed58bc86 100644 --- a/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java +++ b/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java @@ -809,7 +809,7 @@ public class TunnelDispatcher implements Service { } ******/ - public void startup() { + public synchronized void startup() { // Note that we only use the validator for participants and OBEPs, not IBGWs, so // this BW estimate will be high by about 33% assuming 2-hop tunnels average _validator = new BloomFilterIVValidator(_context, getShareBandwidth(_context)); @@ -823,7 +823,7 @@ public class TunnelDispatcher implements Service { return (int) (pct * Math.min(irateKBps, orateKBps)); } - public void shutdown() { + public synchronized void shutdown() { if (_validator != null) _validator.destroy(); _validator = null; @@ -833,6 +833,7 @@ public class TunnelDispatcher implements Service { _participants.clear(); _inboundGateways.clear(); _participatingConfig.clear(); + _leaveJob.clear(); } public void restart() { @@ -866,6 +867,10 @@ public class TunnelDispatcher implements Service { public void add(HopConfig cfg) { _configs.offer(cfg); } + + public void clear() { + _configs.clear(); + } public String getName() { return "Expire participating tunnels"; } public void runJob() { diff --git a/router/java/src/net/i2p/router/tunnel/TunnelGateway.java b/router/java/src/net/i2p/router/tunnel/TunnelGateway.java index bcc3bf207826ea7951bb4bd82aa9e5419910cdb8..03c93b8cef5072aa5a8fcb1890597e1e575b723c 100644 --- a/router/java/src/net/i2p/router/tunnel/TunnelGateway.java +++ b/router/java/src/net/i2p/router/tunnel/TunnelGateway.java @@ -54,7 +54,7 @@ class TunnelGateway { * @param receiver this receives the encrypted message and forwards it off * to the first hop */ - public TunnelGateway(RouterContext context, QueuePreprocessor preprocessor, Sender sender, Receiver receiver) { + protected TunnelGateway(RouterContext context, QueuePreprocessor preprocessor, Sender sender, Receiver receiver) { _context = context; _log = context.logManager().getLog(getClass()); _queue = new ArrayList(4); @@ -192,26 +192,27 @@ class TunnelGateway { public void timeReached() { boolean wantRequeue = false; - int remaining = 0; - long beforeLock = _context.clock().now(); - long afterChecked = -1; + //int remaining = 0; + //long beforeLock = _context.clock().now(); + //long afterChecked = -1; long delayAmount = -1; //if (_queue.size() > 10000) // stay out of the synchronized block // System.out.println("foo!"); synchronized (_queue) { //if (_queue.size() > 10000) // stay in the synchronized block // System.out.println("foo!"); - afterChecked = _context.clock().now(); + //afterChecked = _context.clock().now(); if (!_queue.isEmpty()) { - if ( (remaining > 0) && (_log.shouldLog(Log.DEBUG)) ) - _log.debug("Remaining before delayed flush preprocessing: " + _queue); + //if ( (remaining > 0) && (_log.shouldLog(Log.DEBUG)) ) + // _log.debug("Remaining before delayed flush preprocessing: " + _queue); wantRequeue = _preprocessor.preprocessQueue(_queue, _sender, _receiver); - if (wantRequeue) + if (wantRequeue) { delayAmount = _preprocessor.getDelayAmount(); - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Remaining after delayed flush preprocessing (requeue? " + wantRequeue + "): " + _queue); + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Remaining after delayed flush preprocessing: " + _queue); + } } - remaining = _queue.size(); + //remaining = _queue.size(); } if (wantRequeue)