Changeset 9007db1


Ignore:
Timestamp:
Nov 3, 2013 3:26:21 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f1e7749
Parents:
85c998e
Message:

Expire wasUnreachable entries, so inbound tunnel build failures don't escalate
and the peer doesn't have a severe penalty in the CapacityCalculator? forever.
This may fix the tunnel build problems that started in -10. Or not.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r85c998e r9007db1  
     12013-11-03 zzz
     2 * NetDB: Allow store of leaseset as long as one lease has not expired
     3 * Transport:
     4   - Expire wasUnreachable entries, so inbound tunnel build failures
     5     don't escalate
     6   - Add network status to event log
     7
     82013-11-01 zzz
     9 * Transport: Fix GeoIPv6 (ticket #1096)
     10
    1112013-10-31 zzz
    212 * i2psnark: Always verify file lengths at startup (ticket #1099)
  • router/java/src/net/i2p/router/RouterVersion.java

    r85c998e r9007db1  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 20;
     21    public final static long BUILD = 21;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/TransportImpl.java

    r85c998e r9007db1  
    6262    /** map from routerIdentHash to timestamp (Long) that the peer was last unreachable */
    6363    private final Map<Hash, Long>  _unreachableEntries;
    64     private final Set<Hash> _wasUnreachableEntries;
     64    private final Map<Hash, Long> _wasUnreachableEntries;
    6565    private final Set<InetAddress> _localAddresses;
    6666    /** global router ident -> IP */
    6767    private static final Map<Hash, byte[]> _IPMap;
     68
     69    private static final long UNREACHABLE_PERIOD = 5*60*1000;
     70    private static final long WAS_UNREACHABLE_PERIOD = 30*60*1000;
    6871
    6972    static {
     
    98101        else
    99102            _sendPool = null;
    100         _unreachableEntries = new HashMap(16);
    101         _wasUnreachableEntries = new ConcurrentHashSet(16);
     103        _unreachableEntries = new HashMap(32);
     104        _wasUnreachableEntries = new HashMap(32);
    102105        _localAddresses = new ConcurrentHashSet(4);
    103106        _context.simpleScheduler().addPeriodicEvent(new CleanupUnreachable(), 2 * UNREACHABLE_PERIOD, UNREACHABLE_PERIOD / 2);
     
    702705    public boolean isEstablished(Hash dest) { return false; }
    703706
    704     private static final long UNREACHABLE_PERIOD = 5*60*1000;
    705 
    706707    public boolean isUnreachable(Hash peer) {
    707708        long now = _context.clock().now();
     
    719720
    720721    /** called when we can't reach a peer */
    721     /** This isn't very useful since it is cleared when they contact us */
    722722    public void markUnreachable(Hash peer) {
    723         long now = _context.clock().now();
     723        short status = _context.commSystem().getReachabilityStatus();
     724        if (status == CommSystemFacade.STATUS_DISCONNECTED ||
     725            status == CommSystemFacade.STATUS_HOSED)
     726            return;
     727        Long now = Long.valueOf(_context.clock().now());
    724728        synchronized (_unreachableEntries) {
    725             _unreachableEntries.put(peer, Long.valueOf(now));
    726         }
     729            // This isn't very useful since it is cleared when they contact us
     730            _unreachableEntries.put(peer, now);
     731        }
     732        // This is not cleared when they contact us
    727733        markWasUnreachable(peer, true);
    728734    }
     
    749755                }
    750756            }
     757            synchronized (_wasUnreachableEntries) {
     758                for (Iterator<Long> iter = _wasUnreachableEntries.values().iterator(); iter.hasNext(); ) {
     759                    Long when = iter.next();
     760                    if (when.longValue() + WAS_UNREACHABLE_PERIOD < now)
     761                        iter.remove();
     762                }
     763            }
    751764        }
    752765    }
     
    754767    /**
    755768     * Was the peer UNreachable (outbound only) the last time we tried it?
    756      * This is NOT reset if the peer contacts us and it is never expired.
     769     * This is NOT reset if the peer contacts us.
    757770     */
    758771    public boolean wasUnreachable(Hash peer) {
    759         if (_wasUnreachableEntries.contains(peer))
    760             return true;
     772        long now = _context.clock().now();
     773        synchronized (_wasUnreachableEntries) {
     774            Long when = _wasUnreachableEntries.get(peer);
     775            if (when != null) {
     776                if (when.longValue() + WAS_UNREACHABLE_PERIOD < now) {
     777                    _unreachableEntries.remove(peer);
     778                    return false;
     779                } else {
     780                    return true;
     781                }
     782            }
     783        }
    761784        RouterInfo ri = _context.netDb().lookupRouterInfoLocally(peer);
    762785        if (ri == null)
     
    764787        return null == ri.getTargetAddress(this.getStyle());
    765788    }
     789
    766790    /**
    767791     * Maintain the WasUnreachable list
    768792     */
    769     public void markWasUnreachable(Hash peer, boolean yes) {
    770         if (yes)
    771             _wasUnreachableEntries.add(peer);
    772         else
    773             _wasUnreachableEntries.remove(peer);
     793    private void markWasUnreachable(Hash peer, boolean yes) {
     794        if (yes) {
     795            Long now = Long.valueOf(_context.clock().now());
     796            synchronized (_wasUnreachableEntries) {
     797                _wasUnreachableEntries.put(peer, now);
     798            }
     799        } else {
     800            synchronized (_wasUnreachableEntries) {
     801                _wasUnreachableEntries.remove(peer);
     802            }
     803        }
    774804        if (_log.shouldLog(Log.INFO))
    775805            _log.info(this.getStyle() + " setting wasUnreachable to " + yes + " for " + peer,
Note: See TracChangeset for help on using the changeset viewer.