2006-04-27 jrandom

* Fixed the tunnel expiration desync code (thanks Complication!)
This commit is contained in:
jrandom
2006-04-28 00:08:40 +00:00
committed by zzz
parent 17271ee3f0
commit 7a6a749004
4 changed files with 18 additions and 11 deletions

View File

@ -1,4 +1,7 @@
$Id: history.txt,v 1.461 2006/04/19 12:47:02 jrandom Exp $ $Id: history.txt,v 1.462 2006/04/23 16:06:12 jrandom Exp $
2006-04-27 jrandom
* Fixed the tunnel expiration desync code (thanks Complication!)
* 2006-04-23 0.6.1.17 released * 2006-04-23 0.6.1.17 released

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
* *
*/ */
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.401 $ $Date: 2006/04/19 12:46:53 $"; public final static String ID = "$Revision: 1.402 $ $Date: 2006/04/23 16:06:15 $";
public final static String VERSION = "0.6.1.17"; public final static String VERSION = "0.6.1.17";
public final static long BUILD = 0; public final static long BUILD = 1;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -9,13 +9,21 @@ class ExpireJob extends JobImpl {
private TunnelPool _pool; private TunnelPool _pool;
private TunnelCreatorConfig _cfg; private TunnelCreatorConfig _cfg;
private boolean _leaseUpdated; private boolean _leaseUpdated;
private long _dropAfter;
public ExpireJob(RouterContext ctx, TunnelCreatorConfig cfg, TunnelPool pool) { public ExpireJob(RouterContext ctx, TunnelCreatorConfig cfg, TunnelPool pool) {
super(ctx); super(ctx);
_pool = pool; _pool = pool;
_cfg = cfg; _cfg = cfg;
_leaseUpdated = false; _leaseUpdated = false;
// give 'em some extra time before dropping 'em // we act as if this tunnel expires a random skew before it actually does
getTiming().setStartAfter(cfg.getExpiration()); // + Router.CLOCK_FUDGE_FACTOR); // so we rebuild out of sync. otoh, we will honor tunnel messages on it
// up through the full lifetime of the tunnel, plus a clock skew, since
// others may be sending to the published lease expirations
long expire = cfg.getExpiration();
_dropAfter = expire + Router.CLOCK_FUDGE_FACTOR;
expire -= ctx.random().nextLong(5*60*1000);
cfg.setExpiration(expire);
getTiming().setStartAfter(expire);
} }
public String getName() { public String getName() {
if (_pool.getSettings().isExploratory()) { if (_pool.getSettings().isExploratory()) {
@ -42,7 +50,8 @@ class ExpireJob extends JobImpl {
_pool.removeTunnel(_cfg); _pool.removeTunnel(_cfg);
_leaseUpdated = true; _leaseUpdated = true;
_pool.refreshLeaseSet(); _pool.refreshLeaseSet();
requeue(Router.CLOCK_FUDGE_FACTOR); long timeToDrop = _dropAfter - getContext().clock().now();
requeue(timeToDrop);
} else { } else {
// already removed/refreshed, but now lets make it // already removed/refreshed, but now lets make it
// so we dont even honor the tunnel anymore // so we dont even honor the tunnel anymore

View File

@ -33,11 +33,6 @@ public class PooledTunnelCreatorConfig extends TunnelCreatorConfig {
if (_testJob != null) if (_testJob != null)
_testJob.testSuccessful(ms); _testJob.testSuccessful(ms);
super.testSuccessful(ms); super.testSuccessful(ms);
// once a tunnel has been built and we know it works, lets skew ourselves a bit so we
// aren't as cyclic
if ( (_context.router().getUptime() < 10*60*1000) && (!_live) )
setExpiration(getExpiration() - _context.random().nextInt(5*60*1000));
_live = true; _live = true;
} }