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
This commit is contained in:
@ -182,6 +182,7 @@ public class OutboundClientMessageJob extends JobImpl {
|
|||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn(getJobId() + ": No more leases, and we still haven't heard back from the peer"
|
_log.warn(getJobId() + ": No more leases, and we still haven't heard back from the peer"
|
||||||
+ ", refetching the leaseSet to try again");
|
+ ", refetching the leaseSet to try again");
|
||||||
|
LeaseSet ls = _status.getLeaseSet();
|
||||||
_status.setLeaseSet(null);
|
_status.setLeaseSet(null);
|
||||||
long remainingMs = _overallExpiration - getContext().clock().now();
|
long remainingMs = _overallExpiration - getContext().clock().now();
|
||||||
if (_status.getNumLookups() < MAX_LEASE_LOOKUPS) {
|
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
|
_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().fail(to); // so we don't just fetch what we have
|
||||||
getContext().netDb().lookupLeaseSet(to, _nextStep, _lookupLeaseSetFailed, remainingMs);
|
getContext().netDb().lookupLeaseSet(to, _nextStep, _lookupLeaseSetFailed, remainingMs);
|
||||||
|
if (ls != null)
|
||||||
|
getContext().jobQueue().addJob(new ShortCircuitSearchJob(ls));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
@ -203,6 +206,27 @@ public class OutboundClientMessageJob extends JobImpl {
|
|||||||
getContext().jobQueue().addJob(new SendJob(nextLease));
|
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
|
* 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...).
|
* are no remaining leases available (or there weren't any in the first place...).
|
||||||
|
Reference in New Issue
Block a user