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

Skip to content
Snippets Groups Projects
Commit f9d8a2d7 authored by zzz's avatar zzz
Browse files

allow smaller leasesets

parent cdab99bd
No related branches found
No related tags found
No related merge requests found
......@@ -468,7 +468,9 @@ public class TunnelPool {
if (_tunnels.size() < wanted) {
if (_log.shouldLog(Log.WARN))
_log.warn(toString() + ": Not enough tunnels (" + _tunnels.size() + ", wanted " + wanted + ")");
return null;
// see comment below
if (_tunnels.size() <= 0)
return null;
}
long expireAfter = _context.clock().now(); // + _settings.getRebuildPeriod();
......@@ -492,15 +494,26 @@ public class TunnelPool {
leases.add(lease);
}
// Go ahead and use less leases for now, hopefully a new tunnel will be built soon
// and we will get called again to generate a full leaseset.
// For clients with high tunnel count or length,
// this will make startup considerably faster, and reduce loss of leaseset
// when one tunnel is lost, thus making us much more robust.
// This also helps when returning to full lease count after reduce-on-idle
// or close-on-idle.
// So we will generate a succession of leases at startup. That's OK.
// Do we want a config option for this, or are there times when we shouldn't do this?
if (leases.size() < wanted) {
if (_log.shouldLog(Log.WARN))
_log.warn(toString() + ": Not enough leases (" + leases.size() + ", wanted " + wanted + ")");
return null;
if (leases.size() <= 0)
return null;
}
LeaseSet ls = new LeaseSet();
Iterator iter = leases.iterator();
for (int i = 0; i < wanted; i++)
int count = Math.min(leases.size(), wanted);
for (int i = 0; i < count; i++)
ls.addLease((Lease) iter.next());
if (_log.shouldLog(Log.INFO))
_log.info(toString() + ": built new leaseSet: " + ls);
......
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