Changeset 95fd029


Ignore:
Timestamp:
Jun 13, 2014 1:40:52 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
653ffbc
Parents:
2a269ff
Message:
  • Tunnels: Don't get stuck only building tunnels for an empty pool (ticket #1300)
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r2a269ff r95fd029  
     12014-06-13 zzz
     2 * i2psnark: Fix NPE when fetching invalid torrent (ticket #1307)
     3 * Transports: Disallow Carrier Grade NAT (RFC 6598) addresses
     4 * Tunnels: Don't get stuck only building tunnels
     5   for an empty pool (ticket #1300)
     6
    172014-06-10 zzz
    28 * i2psnark: Fix decoding of negative numbers (ticket #1307)
  • router/java/src/net/i2p/router/RouterVersion.java

    r2a269ff r95fd029  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 6;
     21    public final static long BUILD = 7;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java

    r2a269ff r95fd029  
    340340                        if (wanted.size() > 1) {
    341341                            Collections.shuffle(wanted, _context.random());
     342                            // We generally prioritize pools with no tunnels,
     343                            // but sometimes (particularly at startup), the paired tunnel endpoint
     344                            // can start dropping the build messages... or hit connection limits,
     345                            // or be broken in other ways. So we allow other pools to go
     346                            // to the front of the line sometimes, to prevent being "locked up"
     347                            // for several minutes.
     348                            boolean preferEmpty = _context.random().nextInt(4) != 0;
    342349                            try {
    343                                 Collections.sort(wanted, new TunnelPoolComparator());
     350                                Collections.sort(wanted, new TunnelPoolComparator(preferEmpty));
    344351                            } catch (IllegalArgumentException iae) {
    345352                                // Java 7 TimSort - see info in TunnelPoolComparator
     
    431438     */
    432439    private static class TunnelPoolComparator implements Comparator<TunnelPool> {
     440
     441        private final boolean _preferEmpty;
     442
     443        public TunnelPoolComparator(boolean preferEmptyPools) {
     444            _preferEmpty = preferEmptyPools;
     445        }
     446
    433447        public int compare(TunnelPool tpl, TunnelPool tpr) {
    434448            if (tpl.getSettings().isExploratory() && !tpr.getSettings().isExploratory())
     
    436450            if (tpr.getSettings().isExploratory() && !tpl.getSettings().isExploratory())
    437451                return 1;
    438             if (tpl.getTunnelCount() <= 0 && tpr.getTunnelCount() > 0)
    439                 return -1;
    440             if (tpr.getTunnelCount() <= 0 && tpl.getTunnelCount() > 0)
    441                 return 1;
     452            if (_preferEmpty) {
     453                if (tpl.getTunnelCount() <= 0 && tpr.getTunnelCount() > 0)
     454                    return -1;
     455                if (tpr.getTunnelCount() <= 0 && tpl.getTunnelCount() > 0)
     456                    return 1;
     457            }
    442458            return 0;
    443459        }
Note: See TracChangeset for help on using the changeset viewer.