Changeset aa0616d


Ignore:
Timestamp:
Apr 27, 2014 3:47:43 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
87889bb
Parents:
611ff635
Message:
  • UDP:
    • Locking fixes on rebuilding address
    • Don't rapidly churn address when we don't have enough introducers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r611ff635 raa0616d  
     12014-04-27 zzz
     2 * NTCP: Remove published NTCP address if SSU becomes firewalled,
     3         to fix the "Firewalled with NTCP enabled" message
     4 * Router: Set killVMOnEnd before runRouter() (for azi2phelper)
     5 * RoutingKeyGenerator: Don't assume UTC (for azi2phelper)
     6 * SusiMail:
     7   - Add locking for disk cache
     8   - Remove cancel button from login page
     9   - New configuration page
     10   - Move set page form to configuration page
     11   - Theme and js enhancements
     12 * UDP:
     13   - Locking fixes on rebuilding address
     14   - Don't rapidly churn address when we don't have enough introducers
     15
    1162014-04-25 zzz
    217 * SusiMail:
     
    1025   - Fix repeated re-saves of mail to disk
    1126   - Enable auto-deletion of downloaded mails
     27   - Send delete to server for mails already downloaded
    1228
    13292014-04-24 zzz
  • router/java/src/net/i2p/router/RouterVersion.java

    r611ff635 raa0616d  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 12;
     21    public final static long BUILD = 13;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r611ff635 raa0616d  
    9292    /** do we need to rebuild our external router address asap? */
    9393    private boolean _needsRebuild;
     94    private final Object _rebuildLock = new Object();
    9495   
    9596    /** introduction key */
     
    11601161            _context.statManager().addRateData("udp.alreadyConnected", oldEstablishedOn, 0);
    11611162       
    1162         if (needsRebuild())
    1163             rebuildExternalAddress();
     1163        rebuildIfNecessary();
    11641164       
    11651165        if (getReachabilityStatus() != CommSystemFacade.STATUS_OK) {
     
    13041304            locked_dropPeer(peer, shouldBanlist, why);
    13051305        }
    1306         if (needsRebuild())
    1307             rebuildExternalAddress();
     1306        rebuildIfNecessary();
    13081307    }
    13091308
     
    13501349   
    13511350    /**
    1352      *  Does the IPv4 external address need to be rebuilt?
    1353      */
    1354     private boolean needsRebuild() {
     1351     *  Rebuild the IPv4 external address if required
     1352     */
     1353    private void rebuildIfNecessary() {
     1354        synchronized (_rebuildLock) {
     1355            if (locked_needsRebuild())
     1356                rebuildExternalAddress();
     1357        }
     1358    }
     1359
     1360    private boolean locked_needsRebuild() {
    13551361        if (_needsRebuild) return true; // simple enough
    13561362        if (_context.router().isHidden()) return false;
     
    13681374                    valid++;
    13691375            }
     1376            long sinceSelected = _context.clock().now() - _introducersSelectedOn;
    13701377            if (valid >= PUBLIC_RELAY_COUNT) {
    13711378                // try to shift 'em around every 10 minutes or so
    1372                 if (_introducersSelectedOn < _context.clock().now() - 10*60*1000) {
     1379                if (sinceSelected > 10*60*1000) {
    13731380                    if (_log.shouldLog(Log.WARN))
    1374                         _log.warn("Our introducers are valid, but havent changed in a while, so lets rechoose");
     1381                        _log.warn("Our introducers are valid, but haven't changed in " + DataHelper.formatDuration(sinceSelected) + ", so lets rechoose");
    13751382                    return true;
    13761383                } else {
    13771384                    if (_log.shouldLog(Log.INFO))
    1378                         _log.info("Our introducers are valid and haven't changed in a while");
     1385                        _log.info("Our introducers are valid and were selected " + DataHelper.formatDuration(sinceSelected) + " ago");
    13791386                    return false;
    13801387                }
    1381             } else {
     1388            } else if (sinceSelected > 2*60*1000) {
     1389                // Rate limit to prevent rapid churn after transition to firewalled or at startup
    13821390                if (_log.shouldLog(Log.INFO))
    13831391                    _log.info("Need more introducers (have " +valid + " need " + PUBLIC_RELAY_COUNT + ')');
    13841392                return true;
     1393            } else {
     1394                if (_log.shouldLog(Log.INFO))
     1395                    _log.info("Need more introducers (have " +valid + " need " + PUBLIC_RELAY_COUNT + ')' +
     1396                              " but we just chose them " + DataHelper.formatDuration(sinceSelected) + " ago so wait");
     1397                // TODO also check to see if we actually have more available
     1398                return false;
    13851399            }
    13861400        } else {
     
    17931807     */
    17941808    private RouterAddress rebuildExternalAddress(String host, int port, boolean allowRebuildRouterInfo) {
     1809        synchronized (_rebuildLock) {
     1810            return locked_rebuildExternalAddress(host, port, allowRebuildRouterInfo);
     1811        }
     1812    }
     1813
     1814    private RouterAddress locked_rebuildExternalAddress(String host, int port, boolean allowRebuildRouterInfo) {
    17951815        if (_log.shouldLog(Log.DEBUG))
    17961816            _log.debug("REA4 " + host + ':' + port);
     
    18031823        boolean isIPv6 = host != null && host.contains(":");
    18041824        if (allowDirectUDP() && port > 0 && host != null) {
     1825            // TODO don't add these if we have (or require?) introducers
    18051826            options.setProperty(UDPAddress.PROP_PORT, String.valueOf(port));
    18061827            options.setProperty(UDPAddress.PROP_HOST, host);
     
    29492970   
    29502971    void setReachabilityStatus(short status) {
     2972        synchronized (_rebuildLock) {
     2973            locked_setReachabilityStatus(status);
     2974        }
     2975    }
     2976
     2977    private void locked_setReachabilityStatus(short status) {
    29512978        short old = _reachabilityStatus;
    29522979        long now = _context.clock().now();
     
    29983025        }
    29993026    }
     3027
    30003028    private static final String PROP_REACHABILITY_STATUS_OVERRIDE = "i2np.udp.status";
    30013029
Note: See TracChangeset for help on using the changeset viewer.