Changeset 7ce539a for router


Ignore:
Timestamp:
Feb 25, 2019 2:40:59 PM (17 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a12058d
Parents:
b76b2ef
Message:

NetDB: Fix dup publish of RI at startup
Improve locking for checking address change
Publish RI after netdb is ready
log tweaks

Location:
router/java/src/net/i2p/router
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/Router.java

    rb76b2ef r7ce539a  
    838838     */
    839839    public void setNetDbReady() {
     840        boolean changed = false;
    840841        synchronized(_stateLock) {
    841             if (_state == State.STARTING_3)
     842            if (_state == State.STARTING_3) {
    842843                changeState(State.NETDB_READY);
    843             else if (_state == State.EXPL_TUNNELS_READY)
     844                changed = true;
     845            } else if (_state == State.EXPL_TUNNELS_READY) {
    844846                changeState(State.RUNNING);
     847                changed = true;
     848            }
     849        }
     850        if (changed) {
     851            // any previous calls to netdb().publish() did not
     852            // actually publish, because netdb init was not complete
     853            Republish r = new Republish(_context);
     854            // this is called from PersistentDataStore.ReadJob,
     855            // so we probably don't need to throw it to the timer queue,
     856            // but just to be safe
     857            _context.simpleTimer2().addEvent(r, 0);
    845858        }
    846859    }
     
    906919    public void rebuildRouterInfo(boolean blockingRebuild) {
    907920        if (_log.shouldLog(Log.INFO))
    908             _log.info("Rebuilding new routerInfo");
     921            _log.info("Rebuilding new routerInfo, publish inline? " + blockingRebuild, new Exception("I did it"));
    909922        _routerInfoLock.writeLock().lock();
    910923        try {
  • router/java/src/net/i2p/router/RouterVersion.java

    rb76b2ef r7ce539a  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 9;
     21    public final static long BUILD = 10;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java

    rb76b2ef r7ce539a  
    5050
    5151    /** this needs to be long enough to give us time to start up,
    52         but less than 20m (when we start accepting tunnels and could be a IBGW)
    53         Actually no, we need this soon if we are a new router or
    54         other routers have forgotten about us, else
    55         we can't build IB exploratory tunnels.
     52     *  but less than 20m (when we start accepting tunnels and could be a IBGW)
     53     *  Actually no, we need this soon if we are a new router or
     54     *  other routers have forgotten about us, else
     55     *  we can't build IB exploratory tunnels.
     56     *
     57     *  First publish after netdb ready is now done via state machine
     58     *  in Router.setNetDbReady(), so we probably don't need this anymore
    5659     */
    5760    private static final long FIRST_TIME_DELAY = 90*1000;
     
    143146            requeue(getDelay());
    144147        } else {
     148            // First publish after netdb ready is now done via state machine
     149            // in Router.setNetDbReady(), so we probably don't need this anymore
     150            // but leave it in for now, a router may have trouble publishing right away
    145151            requeue(FIRST_TIME_DELAY);
    146152            _notFirstTime = true;
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    rb76b2ef r7ce539a  
    138138        super.publish(localRouterInfo);
    139139        // wait until we've read in the RI's so we can find the closest floodfill
    140         if (!isInitialized())
     140        if (!isInitialized()) {
     141            if (_log.shouldWarn())
     142                _log.warn("publish() before initialized: " + localRouterInfo, new Exception("I did it"));
    141143            return;
     144        }
    142145        // no use sending if we have no addresses
    143146        // (unless maybe we used to have addresses? not worth it
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    rb76b2ef r7ce539a  
    679679     */
    680680    public void publish(LeaseSet localLeaseSet) throws IllegalArgumentException {
    681         if (!_initialized) return;
     681        if (!_initialized) {
     682            if (_log.shouldWarn())
     683                _log.warn("publish() before initialized: " + localLeaseSet, new Exception("I did it"));
     684            return;
     685        }
    682686        Hash h = localLeaseSet.getDestination().calculateHash();
    683687        try {
  • router/java/src/net/i2p/router/tasks/Republish.java

    rb76b2ef r7ce539a  
    99 */
    1010
     11import net.i2p.data.router.RouterInfo;
    1112import net.i2p.router.Router;
    1213import net.i2p.router.RouterContext;
     
    2829    public void timeReached() {
    2930        try {
    30             _context.netDb().publish(_context.router().getRouterInfo());
     31            RouterInfo ri = _context.router().getRouterInfo();
     32            if (ri != null)
     33                _context.netDb().publish(ri);
    3134        } catch (IllegalArgumentException iae) {
    3235            Log log = _context.logManager().getLog(Router.class);
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    rb76b2ef r7ce539a  
    992992
    993993        boolean isIPv6 = ourIP.length == 16;
    994         RouterAddress current = getCurrentExternalAddress(isIPv6);
    995         byte[] externalListenHost = current != null ? current.getIP() : null;
    996         int externalListenPort = current != null ? current.getPort() : getRequestedPort(isIPv6);
    997 
    998         if (_log.shouldLog(Log.INFO))
    999             _log.info("Change address? status = " + _reachabilityStatus +
     994
     995        synchronized (_rebuildLock) {
     996            RouterAddress current = getCurrentExternalAddress(isIPv6);
     997            byte[] externalListenHost = current != null ? current.getIP() : null;
     998            int externalListenPort = current != null ? current.getPort() : getRequestedPort(isIPv6);
     999
     1000            if (_log.shouldLog(Log.INFO))
     1001                _log.info("Change address? status = " + _reachabilityStatus +
    10001002                      " diff = " + (_context.clock().now() - _reachabilityStatusLastUpdated) +
    10011003                      " old = " + Addresses.toString(externalListenHost, externalListenPort) +
    10021004                      " new = " + Addresses.toString(ourIP, ourPort));
    10031005
    1004         if ((fixedPort && externalListenPort > 0) || ourPort <= 0)
    1005             ourPort = externalListenPort;
    1006 
    1007             synchronized (this) {
     1006            if ((fixedPort && externalListenPort > 0) || ourPort <= 0)
     1007                ourPort = externalListenPort;
     1008
    10081009                if (ourPort > 0 &&
    10091010                    !eq(externalListenHost, externalListenPort, ourIP, ourPort)) {
     
    10301031                        _log.info("Same address as the current one");
    10311032                }
    1032             }
     1033        }
    10331034
    10341035        if (fireTest) {
     
    10881089            }
    10891090            // deadlock thru here ticket #1699
    1090             _context.router().rebuildRouterInfo();
     1091            // this causes duplicate publish, REA() call above calls rebuildRouterInfo
     1092            //_context.router().rebuildRouterInfo();
    10911093            _testEvent.forceRunImmediately(isIPv6);
    10921094        }
Note: See TracChangeset for help on using the changeset viewer.