From 042cde2952f97e4066d2ef0e24c9847984a967f9 Mon Sep 17 00:00:00 2001 From: zzz Date: Sat, 2 Oct 2010 17:04:52 +0000 Subject: [PATCH] * UDP: - Try to avoid running out of introducers by relaxing selection criteria and increasing minimum number of potential introducers --- .../router/transport/udp/IntroductionManager.java | 15 ++++++++++++--- .../i2p/router/transport/udp/UDPTransport.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/udp/IntroductionManager.java b/router/java/src/net/i2p/router/transport/udp/IntroductionManager.java index 6a2707f60..6985164cb 100644 --- a/router/java/src/net/i2p/router/transport/udp/IntroductionManager.java +++ b/router/java/src/net/i2p/router/transport/udp/IntroductionManager.java @@ -96,7 +96,10 @@ public class IntroductionManager { int sz = peers.size(); start = start % sz; int found = 0; - long inactivityCutoff = _context.clock().now() - (UDPTransport.EXPIRE_TIMEOUT / 2); + long inactivityCutoff = _context.clock().now() - (UDPTransport.EXPIRE_TIMEOUT / 2); // 15 min + // if not too many to choose from, be less picky + if (sz <= howMany + 2) + inactivityCutoff -= UDPTransport.EXPIRE_TIMEOUT / 4; for (int i = 0; i < sz && found < howMany; i++) { PeerState cur = peers.get((start + i) % sz); RouterInfo ri = _context.netDb().lookupRouterInfoLocally(cur.getRemotePeer()); @@ -119,7 +122,11 @@ public class IntroductionManager { continue; } // Try to pick active peers... - if (cur.getLastReceiveTime() < inactivityCutoff || cur.getLastSendTime() < inactivityCutoff) { + // FIXME this is really strict and causes us to run out of introducers + // We have much less introducers than we used to have because routers don't offer + // if they are approaching max connections (see EstablishmentManager) + // FIXED, was ||, is this OK now? + if (cur.getLastReceiveTime() < inactivityCutoff && cur.getLastSendTime() < inactivityCutoff) { if (_log.shouldLog(Log.INFO)) _log.info("Peer is idle too long: " + cur); continue; @@ -135,6 +142,8 @@ public class IntroductionManager { found++; } + // FIXME failsafe if found == 0, relax inactivityCutoff and try again? + // Try to keep the connection up for two hours after we made anybody an introducer long pingCutoff = _context.clock().now() - (2 * 60 * 60 * 1000); inactivityCutoff = _context.clock().now() - (UDPTransport.EXPIRE_TIMEOUT / 4); @@ -156,7 +165,7 @@ public class IntroductionManager { * Not as elaborate as pickInbound() above. * Just a quick check to see how many volunteers we know, * which the Transport uses to see if we need more. - * @return number of peers that have volunteerd to introduce us + * @return number of peers that have volunteered to introduce us */ int introducerCount() { return _inbound.size(); diff --git a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java index 0617790a3..390a741f1 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java @@ -1017,7 +1017,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority /** minimum active peers to maintain IP detection, etc. */ private static final int MIN_PEERS = 3; /** minimum peers volunteering to be introducers if we need that */ - private static final int MIN_INTRODUCER_POOL = 4; + private static final int MIN_INTRODUCER_POOL = 5; public TransportBid bid(RouterInfo toAddress, long dataSize) { if (dataSize > OutboundMessageState.MAX_MSG_SIZE) {