* NetDb: Don't drop routerInfos if we have connectivity issues or other problems
This commit is contained in:
@ -20,6 +20,7 @@ import net.i2p.router.JobImpl;
|
||||
import net.i2p.router.MessageSelector;
|
||||
import net.i2p.router.OutNetMessage;
|
||||
import net.i2p.router.ReplyJob;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.TunnelInfo;
|
||||
import net.i2p.util.Log;
|
||||
@ -256,7 +257,27 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
|
||||
return sel.selectFloodfillParticipants(getKBuckets());
|
||||
}
|
||||
|
||||
/** NTCP cons drop quickly but SSU takes a while, so it's prudent to keep this
|
||||
* a little higher than 1 or 2. */
|
||||
protected final static int MIN_ACTIVE_PEERS = 5;
|
||||
|
||||
/**
|
||||
* Search for a newer router info, drop it from the db if the search fails,
|
||||
* unless just started up or have bigger problems.
|
||||
*/
|
||||
protected void lookupBeforeDropping(Hash peer, RouterInfo info) {
|
||||
// following are some special situations, we don't want to
|
||||
// drop the peer in these cases
|
||||
// yikes don't do this - stack overflow // getFloodfillPeers().size() == 0 ||
|
||||
if (info.getNetworkId() == Router.NETWORK_ID &&
|
||||
(getKnownRouters() < MIN_REMAINING_ROUTERS ||
|
||||
_context.router().getUptime() < DONT_FAIL_PERIOD ||
|
||||
_context.commSystem().countActivePeers() <= MIN_ACTIVE_PEERS)) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Not failing " + peer.toBase64() + " as we are just starting up or have problems");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_context.jobQueue().getMaxLag() > 500) {
|
||||
// don't try to overload ourselves (e.g. failing 3000 router refs at
|
||||
// once, and then firing off 3000 netDb lookup tasks)
|
||||
|
@ -99,7 +99,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
* offline for a while, we'll have a chance of finding some live peers with the
|
||||
* previous references
|
||||
*/
|
||||
private final static long DONT_FAIL_PERIOD = 10*60*1000;
|
||||
protected final static long DONT_FAIL_PERIOD = 10*60*1000;
|
||||
|
||||
/** don't probe or broadcast data, just respond and search when explicitly needed */
|
||||
private boolean _quiet = false;
|
||||
@ -111,8 +111,10 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
public final static String PROP_DB_DIR = "router.networkDatabase.dbDir";
|
||||
public final static String DEFAULT_DB_DIR = "netDb";
|
||||
|
||||
/** if we have less than 5 routers left, don't drop any more, even if they're failing or doing bad shit */
|
||||
private final static int MIN_REMAINING_ROUTERS = 5;
|
||||
/** if we have less than this many routers left, don't drop any more,
|
||||
* even if they're failing or doing bad shit.
|
||||
*/
|
||||
protected final static int MIN_REMAINING_ROUTERS = 25;
|
||||
|
||||
/**
|
||||
* dont accept any dbDtore of a router over 24 hours old (unless we dont
|
||||
@ -756,24 +758,6 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
isRouterInfo = true;
|
||||
|
||||
if (isRouterInfo) {
|
||||
if (((RouterInfo)o).getNetworkId() != Router.NETWORK_ID) {
|
||||
// definitely drop them
|
||||
} else {
|
||||
int remaining = _kb.size();
|
||||
if (remaining < MIN_REMAINING_ROUTERS) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Not removing " + dbEntry + " because we have so few routers left ("
|
||||
+ remaining + ") - perhaps a reseed is necessary?");
|
||||
return;
|
||||
}
|
||||
if (System.currentTimeMillis() < _started + DONT_FAIL_PERIOD) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Not failing the key " + dbEntry.toBase64()
|
||||
+ " since we've just started up and don't want to drop /everyone/");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lookupBeforeDropping(dbEntry, (RouterInfo)o);
|
||||
return;
|
||||
} else {
|
||||
@ -806,6 +790,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
}
|
||||
}
|
||||
|
||||
/** don't use directly - see F.N.D.F. override */
|
||||
protected void lookupBeforeDropping(Hash peer, RouterInfo info) {
|
||||
//bah, humbug.
|
||||
dropAfterLookupFailed(peer, info);
|
||||
|
@ -311,8 +311,11 @@ public class TransportManager implements TransportEventListener {
|
||||
}
|
||||
}
|
||||
if (unreachableTransports >= _transports.size()) {
|
||||
// Don't shitlist if we aren't talking to anybody, as we may have a network connection issue
|
||||
if (unreachableTransports >= _transports.size() && countActivePeers() > 0) {
|
||||
_context.statManager().addRateData("transport.shitlistOnUnreachable", msg.getLifetime(), msg.getLifetime());
|
||||
_context.shitlist().shitlistRouter(peer, "Unreachable on any transport");
|
||||
}
|
||||
} else if (rv == null) {
|
||||
_context.statManager().addRateData("transport.noBidsYetNotAllUnreachable", unreachableTransports, msg.getLifetime());
|
||||
}
|
||||
|
Reference in New Issue
Block a user