Changeset 87889bb


Ignore:
Timestamp:
Apr 27, 2014 6:46:11 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
1dfbe73
Parents:
aa0616d
Message:
  • UDP:
    • Locking fixes on peer testing
    • More locking fixes on rebuilding address
    • Slow down peer test frequency, esp. when firewalled
  • Transports:
    • Deprecate unused recheckReachability()
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java

    raa0616d r87889bb  
    5858        if (_saveRequested || ( (_action != null) && (_("Save changes").equals(_action)) )) {
    5959            saveChanges();
    60         } else if (_recheckReachabilityRequested) {
    61             recheckReachability();
     60        //} else if (_recheckReachabilityRequested) {
     61        //    recheckReachability();
    6262        } else {
    6363            // noop
     
    138138    }
    139139   
     140/****
    140141    private void recheckReachability() {
    141142        _context.commSystem().recheckReachability();
    142143        addFormNotice(_("Rechecking router reachability..."));
    143144    }
     145****/
    144146   
    145147    /**
  • router/java/src/net/i2p/router/CommSystemFacade.java

    raa0616d r87889bb  
    5454     */
    5555    public short getReachabilityStatus() { return STATUS_OK; }
     56
     57    /**
     58     * @deprecated unused
     59     */
    5660    public void recheckReachability() {}
     61
    5762    public boolean isBacklogged(Hash dest) { return false; }
    5863    public boolean wasUnreachable(Hash dest) { return false; }
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    raa0616d r87889bb  
    174174        return rv;
    175175    }
     176
     177    /**
     178     * @deprecated unused
     179     */
    176180    @Override
    177181    public void recheckReachability() { _manager.recheckReachability(); }
  • router/java/src/net/i2p/router/transport/Transport.java

    raa0616d r87889bb  
    133133    public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException;
    134134    public short getReachabilityStatus();
     135
     136    /**
     137     * @deprecated unused
     138     */
    135139    public void recheckReachability();
     140
    136141    public boolean isBacklogged(Hash peer);
    137142
  • router/java/src/net/i2p/router/transport/TransportImpl.java

    raa0616d r87889bb  
    704704
    705705    public short getReachabilityStatus() { return CommSystemFacade.STATUS_UNKNOWN; }
     706
     707    /**
     708     * @deprecated unused
     709     */
    706710    public void recheckReachability() {}
     711
    707712    public boolean isBacklogged(Hash dest) { return false; }
    708713    public boolean isEstablished(Hash dest) { return false; }
  • router/java/src/net/i2p/router/transport/TransportManager.java

    raa0616d r87889bb  
    309309    }
    310310
     311    /**
     312     * @deprecated unused
     313     */
    311314    public void recheckReachability() {
    312315        for (Transport t : _transports.values())
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    raa0616d r87889bb  
    7878    private short _reachabilityStatus;
    7979    private long _reachabilityStatusLastUpdated;
     80    private int _reachabilityStatusUnchanged;
    8081    private long _introducersSelectedOn;
    8182    private long _lastInboundReceivedOn;
     
    190191    public static final int DEFAULT_COST = 5;
    191192    private static final int TEST_FREQUENCY = 13*60*1000;
     193    private static final int MIN_TEST_FREQUENCY = 45*1000;
    192194    static final long[] RATES = { 10*60*1000 };
    193195   
     
    910912            _context.router().rebuildRouterInfo();
    911913        }
    912         _testEvent.forceRun();
    913         _testEvent.reschedule(5*1000);
     914        _testEvent.forceRunImmediately();
    914915        return updated;
    915916    }
     
    11611162            _context.statManager().addRateData("udp.alreadyConnected", oldEstablishedOn, 0);
    11621163       
    1163         rebuildIfNecessary();
    1164        
    1165         if (getReachabilityStatus() != CommSystemFacade.STATUS_OK) {
    1166             _testEvent.forceRun();
    1167             _testEvent.reschedule(0);
     1164        synchronized(_rebuildLock) {
     1165            rebuildIfNecessary();
     1166            if (getReachabilityStatus() != CommSystemFacade.STATUS_OK &&
     1167                _reachabilityStatusUnchanged < 7) {
     1168                _testEvent.forceRunSoon();
     1169            }
    11681170        }
    11691171        return true;
     
    18321834        boolean introducersIncluded = false;
    18331835        if (introducersRequired || !directIncluded) {
     1836            // FIXME intro manager doesn't sort introducers, so
     1837            // deepEquals() below can fail even with same introducers.
     1838            // Only a problem when we have very very few peers to pick from.
    18341839            int found = _introManager.pickInbound(options, PUBLIC_RELAY_COUNT);
    18351840            if (found > 0) {
     
    30153020                break;
    30163021        }
     3022        _testEvent.setLastTested();
     3023        if (status != CommSystemFacade.STATUS_UNKNOWN) {
     3024            if (status != old)
     3025                _reachabilityStatusUnchanged = 0;
     3026            else
     3027                _reachabilityStatusUnchanged++;
     3028        }
    30173029        if ( (status != old) && (status != CommSystemFacade.STATUS_UNKNOWN) ) {
    3018             if (_log.shouldLog(Log.INFO))
    3019                 _log.info("Old status: " + old + " New status: " + status + " from: ", new Exception("traceback"));
     3030            if (_log.shouldLog(Log.WARN))
     3031                _log.warn("Old status: " + old + " New status: " + status + " from: ", new Exception("traceback"));
    30203032            // Always rebuild when the status changes, even if our address hasn't changed,
    30213033            // as rebuildExternalAddress() calls replaceAddress() which calls CSFI.notifyReplaceAddress()
     
    30233035            // if (needsRebuild())
    30243036                rebuildExternalAddress();
     3037        } else {
     3038            if (_log.shouldLog(Log.INFO))
     3039                _log.info("Status unchanged: " + _reachabilityStatus + " (" + _reachabilityStatusUnchanged + " consecutive times), last updated " +
     3040                          DataHelper.formatDuration(_context.clock().now() - _reachabilityStatusLastUpdated) + " ago");
    30253041        }
    30263042    }
     
    30443060    }
    30453061
     3062    /**
     3063     * @deprecated unused
     3064     */
    30463065    @Override
    30473066    public void recheckReachability() {
    3048         _testEvent.runTest();
     3067        // FIXME locking if we do this again
     3068        //_testEvent.runTest();
    30493069    }
    30503070   
     
    31063126     */
    31073127    private class PeerTestEvent extends SimpleTimer2.TimedEvent {
    3108         private volatile boolean _alive;
     3128        private boolean _alive;
    31093129        /** when did we last test our reachability */
    31103130        private long _lastTested;
     
    31153135        }
    31163136       
    3117         public void timeReached() {
     3137        public synchronized void timeReached() {
    31183138            if (shouldTest()) {
    3119                 long now = _context.clock().now();
    3120                 if ( (_forceRun) || (now - _lastTested >= TEST_FREQUENCY) ) {
    3121                     runTest();
     3139                long sinceRun = _context.clock().now() - _lastTested;
     3140                if ( (_forceRun && sinceRun >= MIN_TEST_FREQUENCY) || (sinceRun >= TEST_FREQUENCY) ) {
     3141                    locked_runTest();
    31223142                }
    31233143            }
    31243144            if (_alive) {
    31253145                long delay = (TEST_FREQUENCY / 2) + _context.random().nextInt(TEST_FREQUENCY);
    3126                 if (delay <= 0)
    3127                     throw new RuntimeException("wtf, delay is " + delay);
    31283146                schedule(delay);
    31293147            }
    31303148        }
    31313149       
    3132         private void runTest() {
     3150        private void locked_runTest() {
    31333151            PeerState bob = pickTestPeer(BOB, null);
    31343152            if (bob != null) {
     
    31463164        }
    31473165       
    3148         void forceRun() { _forceRun = true; }
    3149        
    3150         public void setIsAlive(boolean isAlive) {
     3166        /**
     3167         *  Run within the next 45 seconds at the latest
     3168         *  @since 0.9.13
     3169         */
     3170        public synchronized void forceRunSoon() {
     3171            _forceRun = true;
     3172            reschedule(MIN_TEST_FREQUENCY);
     3173        }
     3174       
     3175        /**
     3176         *
     3177         *  Run within the next 5 seconds at the latest
     3178         *  @since 0.9.13
     3179         */
     3180        public synchronized void forceRunImmediately() {
     3181            _lastTested = 0;
     3182            _forceRun = true;
     3183            reschedule(5*1000);
     3184        }
     3185       
     3186        public synchronized void setIsAlive(boolean isAlive) {
    31513187            _alive = isAlive;
    31523188            if (isAlive) {
     
    31573193            }
    31583194        }
     3195
     3196        /**
     3197         *  Set the last-tested timer to now
     3198         *  @since 0.9.13
     3199         */
     3200        public synchronized void setLastTested() {
     3201            _lastTested = _context.clock().now();
     3202        }
     3203       
    31593204    }
    31603205   
Note: See TracChangeset for help on using the changeset viewer.