Changeset 9fba125


Ignore:
Timestamp:
Feb 18, 2016 10:27:17 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
910822e
Parents:
3a28680
Message:

Transport:

  • Implement mayDisconnect() for outbound connections also
  • Run UDP idle disconnect loop faster if floodfill or near connection limit

NetDB:

  • Call mayDisconnect() after direct netdb store
  • Fix check to publish RI faster, broken in .24, we were publishing at every check, causing increased load on floodfills
Location:
router/java/src/net/i2p/router
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java

    r3a28680 r9fba125  
    8787                // If something changed, including the cost, then publish,
    8888                // otherwise don't.
    89                 boolean different = !oldRI.getCapabilities().equals(ri.getCapabilities());
     89                String newcaps = getContext().router().getCapabilities();
     90                boolean different = !oldRI.getCapabilities().equals(newcaps);
    9091                if (!different) {
    9192                    Comparator<RouterAddress> comp = new AddrComparator();
     
    108109                if (_log.shouldLog(Log.INFO))
    109110                    _log.info("Republishing early because addresses or costs or caps have changed -" +
    110                               " oldCaps: " + oldRI.getCapabilities() + " newCaps: " + ri.getCapabilities() +
     111                              " oldCaps: " + oldRI.getCapabilities() + " newCaps: " + newcaps +
    111112                              " old:\n" +
    112113                              oldAddrs + "\nnew:\n" + newAddrs);
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r3a28680 r9fba125  
    563563        private final int _msgSize;
    564564       
     565        /** direct */
    565566        public SendSuccessJob(RouterContext enclosingContext, RouterInfo peer) {
    566567            this(enclosingContext, peer, null, 0);
    567568        }
     569
     570        /** through tunnel */
    568571        public SendSuccessJob(RouterContext enclosingContext, RouterInfo peer, TunnelInfo sendThrough, int size) {
    569572            super(enclosingContext);
     
    597600                    getContext().profileManager().tunnelDataPushed(_sendThrough.getPeer(i), howLong, _msgSize);
    598601                _sendThrough.incrementVerifiedBytesTransferred(_msgSize);
     602            }
     603            if (_sendThrough == null) {
     604                // advise comm system, to reduce lifetime of direct connections to floodfills
     605                getContext().commSystem().mayDisconnect(_peer.getHash());
    599606            }
    600607           
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    r3a28680 r9fba125  
    274274                               
    275275                                final long expire;
    276                                 if (!haveCap && con.getMayDisconnect() &&
     276                                if ((!haveCap || !con.isInbound()) &&
     277                                    con.getMayDisconnect() &&
    277278                                    con.getMessagesReceived() <= 2 && con.getMessagesSent() <= 1) {
    278279                                    expire = MAY_DISCON_TIMEOUT;
     280                                    if (_log.shouldInfo())
     281                                        _log.info("Possible early disconnect for " + con);
    279282                                } else {
    280283                                    expire = _expireIdleWriteTime;
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r3a28680 r9fba125  
    496496    public void mayDisconnect(final Hash peer) {
    497497        final NTCPConnection con = _conByIdent.get(peer);
    498         if (con != null && con.isEstablished() && con.isInbound() &&
     498        if (con != null && con.isEstablished() &&
    499499            con.getMessagesReceived() <= 2 && con.getMessagesSent() <= 1) {
    500500            con.setMayDisconnect();
  • router/java/src/net/i2p/router/transport/udp/PeerState.java

    r3a28680 r9fba125  
    774774    }
    775775
     776    /** the last time we used them as an introducer, or 0 */
    776777    public long getIntroducerTime() { return _lastIntroducerTime; }
     778
     779    /** set the last time we used them as an introducer to now */
    777780    public void setIntroducerTime() { _lastIntroducerTime = _context.clock().now(); }
    778781   
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r3a28680 r9fba125  
    25052505    public void mayDisconnect(final Hash peer) {
    25062506        final PeerState ps =  _peersByIdent.get(peer);
    2507         if (ps != null && ps.isInbound() &&
     2507        if (ps != null &&
    25082508            ps.getWeRelayToThemAs() <= 0 &&
     2509            (ps.getTheyRelayToUsAs() <= 0 || ps.getIntroducerTime() < _context.clock().now() - 2*60*60*1000) &&
    25092510            ps.getMessagesReceived() <= 2 && ps.getMessagesSent() <= 2) {
    25102511            ps.setMayDisconnect();
     
    29362937            int currentListenPort = getListenPort(false);
    29372938            boolean pingOneOnly = shouldPingFirewall && getExternalPort(false) == currentListenPort;
    2938             boolean shortLoop = shouldPingFirewall;
     2939            boolean shortLoop = shouldPingFirewall || !haveCap || _context.netDb().floodfillEnabled();
    29392940            _lastLoopShort = shortLoop;
    29402941            _expireBuffer.clear();
     
    29472948                    if (peer.getWeRelayToThemAs() > 0 || peer.getIntroducerTime() > pingCutoff) {
    29482949                        inactivityCutoff = longInactivityCutoff;
    2949                     } else if (!haveCap && peer.getMayDisconnect() &&
     2950                    } else if ((!haveCap || !peer.isInbound()) &&
     2951                               peer.getMayDisconnect() &&
    29502952                               peer.getMessagesReceived() <= 2 && peer.getMessagesSent() <= 2) {
     2953                        if (_log.shouldInfo())
     2954                            _log.info("Possible early disconnect for: " + peer);
    29512955                        inactivityCutoff = mayDisconCutoff;
    29522956                    } else {
Note: See TracChangeset for help on using the changeset viewer.