I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit b9e667e1 authored by jrandom's avatar jrandom Committed by zzz
Browse files

if a netDb refetch of a lease we were able to fetch is going slowly, short...

if a netDb refetch of a lease we were able to fetch is going slowly, short circuit it by reinjecting the old (dropped) one after 10 seconds so we can attempt a resend
parent 3cd26781
No related branches found
No related tags found
No related merge requests found
......@@ -182,6 +182,7 @@ public class OutboundClientMessageJob extends JobImpl {
if (_log.shouldLog(Log.WARN))
_log.warn(getJobId() + ": No more leases, and we still haven't heard back from the peer"
+ ", refetching the leaseSet to try again");
LeaseSet ls = _status.getLeaseSet();
_status.setLeaseSet(null);
long remainingMs = _overallExpiration - getContext().clock().now();
if (_status.getNumLookups() < MAX_LEASE_LOOKUPS) {
......@@ -190,6 +191,8 @@ public class OutboundClientMessageJob extends JobImpl {
_status.clearAlreadySent(); // so we can send down old tunnels again
getContext().netDb().fail(to); // so we don't just fetch what we have
getContext().netDb().lookupLeaseSet(to, _nextStep, _lookupLeaseSetFailed, remainingMs);
if (ls != null)
getContext().jobQueue().addJob(new ShortCircuitSearchJob(ls));
return;
} else {
if (_log.shouldLog(Log.WARN))
......@@ -203,6 +206,27 @@ public class OutboundClientMessageJob extends JobImpl {
getContext().jobQueue().addJob(new SendJob(nextLease));
}
private static final long MAX_SEARCH_INTERVAL = 10*1000;
/**
* If the netDb refetch isn't going well, lets fall back on the old leaseSet
* anyway
*
*/
private class ShortCircuitSearchJob extends JobImpl {
private LeaseSet _ls;
public ShortCircuitSearchJob(LeaseSet ls) {
super(OutboundClientMessageJob.this.getContext());
_ls = ls;
ShortCircuitSearchJob.this.getTiming().setStartAfter(getContext().clock().now() + MAX_SEARCH_INTERVAL);
}
public String getName() { return "Short circuit search"; }
public void runJob() {
LeaseSet ls = getContext().netDb().lookupLeaseSetLocally(_ls.getDestination().calculateHash());
if (ls == null)
getContext().netDb().store(_ls.getDestination().calculateHash(), _ls);
}
}
/**
* fetch the next lease that we should try sending through, or null if there
* are no remaining leases available (or there weren't any in the first place...).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment