diff --git a/history.txt b/history.txt index 89e0e109c..2dd4b29d2 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,9 @@ +2014-06-13 zzz + * i2psnark: Fix NPE when fetching invalid torrent (ticket #1307) + * Transports: Disallow Carrier Grade NAT (RFC 6598) addresses + * Tunnels: Don't get stuck only building tunnels + for an empty pool (ticket #1300) + 2014-06-10 zzz * i2psnark: Fix decoding of negative numbers (ticket #1307) * NewsFetcher: Only treat correct status codes as success diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index c10128fe6..fecba78d6 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 = 6; + public final static long BUILD = 7; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java b/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java index 5d43deefb..c0ac6daf6 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java @@ -339,8 +339,15 @@ class BuildExecutor implements Runnable { if ( (allowed > 0) && (!wanted.isEmpty()) ) { if (wanted.size() > 1) { Collections.shuffle(wanted, _context.random()); + // We generally prioritize pools with no tunnels, + // but sometimes (particularly at startup), the paired tunnel endpoint + // can start dropping the build messages... or hit connection limits, + // or be broken in other ways. So we allow other pools to go + // to the front of the line sometimes, to prevent being "locked up" + // for several minutes. + boolean preferEmpty = _context.random().nextInt(4) != 0; try { - Collections.sort(wanted, new TunnelPoolComparator()); + Collections.sort(wanted, new TunnelPoolComparator(preferEmpty)); } catch (IllegalArgumentException iae) { // Java 7 TimSort - see info in TunnelPoolComparator continue; @@ -430,15 +437,24 @@ class BuildExecutor implements Runnable { * during the sort. This will cause Java 7 sort to throw an IAE. */ private static class TunnelPoolComparator implements Comparator { + + private final boolean _preferEmpty; + + public TunnelPoolComparator(boolean preferEmptyPools) { + _preferEmpty = preferEmptyPools; + } + public int compare(TunnelPool tpl, TunnelPool tpr) { if (tpl.getSettings().isExploratory() && !tpr.getSettings().isExploratory()) return -1; if (tpr.getSettings().isExploratory() && !tpl.getSettings().isExploratory()) return 1; - if (tpl.getTunnelCount() <= 0 && tpr.getTunnelCount() > 0) - return -1; - if (tpr.getTunnelCount() <= 0 && tpl.getTunnelCount() > 0) - return 1; + if (_preferEmpty) { + if (tpl.getTunnelCount() <= 0 && tpr.getTunnelCount() > 0) + return -1; + if (tpr.getTunnelCount() <= 0 && tpl.getTunnelCount() > 0) + return 1; + } return 0; } }