diff --git a/history.txt b/history.txt index 375fae82d9..dfc453cf7a 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,15 @@ +2020-03-24 zzz + * Tunnels: Make new tunnel selection round-robin + +2020-03-20 zzz + * Tunnels: FragmentHandler cleanup (ticket #2699) + +2020-03-17 zzz + * i2psnark: Hide non-i2p trackers on details page + +2020-03-15 zzz + * Ratchet: Stub out ack and ack request blocks + 2020-03-01 zzz * Console: - Disable browser launch on /configclients when a service diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 0725033fa6..f6e6df3a5c 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 3; + public final static long BUILD = 4; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java index 82befb362e..3839fa5c77 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java +++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java @@ -40,8 +40,7 @@ public class TunnelPool { private final TunnelPoolManager _manager; protected volatile boolean _alive; private long _lifetimeProcessed; - private TunnelInfo _lastSelected; - private long _lastSelectionPeriod; + private int _lastSelectedIdx; private final int _expireSkew; private long _started; private long _lastRateUpdate; @@ -124,8 +123,6 @@ public class TunnelPool { if (_log.shouldLog(Log.WARN)) _log.warn(toString() + ": Shutdown called"); _alive = false; - _lastSelectionPeriod = 0; - _lastSelected = null; _context.statManager().removeRateStat(_rateName); synchronized (_inProgress) { _inProgress.clear(); @@ -152,20 +149,6 @@ public class TunnelPool { _settings.readFromProperties(TunnelPoolSettings.PREFIX_OUTBOUND_EXPLORATORY, props); } - /** - * when selecting tunnels, stick with the same one for a brief - * period to allow batching if we can. - */ - private long curPeriod() { - long period = _context.clock().now(); - long ms = period % 1000; - if (ms > 500) - period = period - ms + 500; - else - period = period - ms; - return period; - } - private long getLifetime() { return System.currentTimeMillis() - _started; } /** @@ -180,33 +163,24 @@ public class TunnelPool { private TunnelInfo selectTunnel(boolean allowRecurseOnFail) { boolean avoidZeroHop = !_settings.getAllowZeroHop(); - long period = curPeriod(); synchronized (_tunnels) { - if (_lastSelectionPeriod == period) { - if ( (_lastSelected != null) && - (_lastSelected.getExpiration() > period) && - (_tunnels.contains(_lastSelected)) ) - return _lastSelected; - } - _lastSelectionPeriod = period; - _lastSelected = null; - if (_tunnels.isEmpty()) { if (_log.shouldLog(Log.WARN)) _log.warn(toString() + ": No tunnels to select from"); } else { - Collections.shuffle(_tunnels, _context.random()); // if there are nonzero hop tunnels and the zero hop tunnels are fallbacks, // avoid the zero hop tunnels TunnelInfo backloggedTunnel = null; if (avoidZeroHop) { for (int i = 0; i < _tunnels.size(); i++) { - TunnelInfo info = _tunnels.get(i); + _lastSelectedIdx++; + if (_lastSelectedIdx >= _tunnels.size()) + _lastSelectedIdx = 0; + TunnelInfo info = _tunnels.get(_lastSelectedIdx); if ( (info.getLength() > 1) && (info.getExpiration() > _context.clock().now()) ) { // avoid outbound tunnels where the 1st hop is backlogged if (_settings.isInbound() || !_context.commSystem().isBacklogged(info.getPeer(1))) { - _lastSelected = info; return info; } else { backloggedTunnel = info; @@ -229,7 +203,6 @@ public class TunnelPool { if (_settings.isInbound() || info.getLength() <= 1 || !_context.commSystem().isBacklogged(info.getPeer(1))) { //_log.debug("Selecting tunnel: " + info + " - " + _tunnels); - _lastSelected = info; return info; } else { backloggedTunnel = info; @@ -505,10 +478,6 @@ public class TunnelPool { if (_settings.isInbound() && !_settings.isExploratory()) ls = locked_buildNewLeaseSet(); remaining = _tunnels.size(); - if (_lastSelected == info) { - _lastSelected = null; - _lastSelectionPeriod = 0; - } } _manager.getExecutor().repoll(); @@ -573,10 +542,6 @@ public class TunnelPool { return; if (_settings.isInbound() && !_settings.isExploratory()) ls = locked_buildNewLeaseSet(); - if (_lastSelected == cfg) { - _lastSelected = null; - _lastSelectionPeriod = 0; - } } _manager.tunnelFailed();