From a6728a33dae8fcc23d29c0c0800bb0439cea51a4 Mon Sep 17 00:00:00 2001 From: zzz Date: Mon, 29 Aug 2011 17:53:01 +0000 Subject: [PATCH] cleanups --- history.txt | 14 ++++++++ .../src/net/i2p/data/i2np/I2NPMessage.java | 2 +- .../src/net/i2p/router/RouterVersion.java | 2 +- .../OutboundClientMessageOneShotJob.java | 35 +++++++++++-------- .../router/transport/udp/PacketHandler.java | 9 +++-- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/history.txt b/history.txt index a3719969c..f46843576 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,17 @@ +2011-08-29 zzz + * NetDB: + - Replace the old parallel lookup method with a true + Kademlia lookup that iteratively queries additional floodfill + peers returned in DatabaseSearchReplyMessages. This is a more + efficient and reliable lookup that will work much better + when not all floodfill peers are known, and it removes a serious + limitation to network growth. + - Limit max number of DSRM entries to look up + - Cleanups, javadocs, log tweaks + * Tunnels: + - Increase timeouts on all deferred netdb lookups to 15s; add lookup stats + - Cleanups, javadocs, log tweaks + 2011-08-28 zzz * checkcerts.sh: New test * Console: Remove 'firewalled and fast' message, just say 'firewalled' diff --git a/router/java/src/net/i2p/data/i2np/I2NPMessage.java b/router/java/src/net/i2p/data/i2np/I2NPMessage.java index c7a19acb2..e2e5290ef 100644 --- a/router/java/src/net/i2p/data/i2np/I2NPMessage.java +++ b/router/java/src/net/i2p/data/i2np/I2NPMessage.java @@ -60,7 +60,7 @@ public interface I2NPMessage extends DataStructure { public int getType(); /** - * Replay resistent message Id + * Replay resistant message ID */ public long getUniqueId(); public void setUniqueId(long id); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 0725033fa..f6e6df3a5 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 3; + public final static long BUILD = 4; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java index 11151424b..13cd85267 100644 --- a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java +++ b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java @@ -186,13 +186,11 @@ public class OutboundClientMessageOneShotJob extends JobImpl { return; } if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": Send outbound client message job beginning"); + _log.debug(getJobId() + ": Send outbound client message job beginning" + + ": preparing to search for the leaseSet for " + _toString); long timeoutMs = _overallExpiration - now; - if (_log.shouldLog(Log.DEBUG)) - _log.debug(getJobId() + ": preparing to search for the leaseSet for " + _toString); Hash key = _to.calculateHash(); SendJob success = new SendJob(getContext()); - LookupLeaseSetFailedJob failed = new LookupLeaseSetFailedJob(getContext()); LeaseSet ls = getContext().netDb().lookupLeaseSetLocally(key); if (ls != null) { getContext().statManager().addRateData("client.leaseSetFoundLocally", 1, 0); @@ -204,6 +202,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl { _leaseSetLookupBegin = getContext().clock().now(); if (_log.shouldLog(Log.DEBUG)) _log.debug(getJobId() + ": Send outbound client message - sending off leaseSet lookup job for " + _toString); + LookupLeaseSetFailedJob failed = new LookupLeaseSetFailedJob(getContext()); getContext().netDb().lookupLeaseSet(key, success, failed, timeoutMs); } } @@ -588,11 +587,12 @@ public class OutboundClientMessageOneShotJob extends JobImpl { } private class DispatchJob extends JobImpl { - private GarlicMessage _msg; - private ReplySelector _selector; - private SendSuccessJob _replyFound; - private SendTimeoutJob _replyTimeout; - private int _timeoutMs; + private final GarlicMessage _msg; + private final ReplySelector _selector; + private final SendSuccessJob _replyFound; + private final SendTimeoutJob _replyTimeout; + private final int _timeoutMs; + public DispatchJob(RouterContext ctx, GarlicMessage msg, ReplySelector sel, SendSuccessJob success, SendTimeoutJob timeout, int timeoutMs) { super(ctx); _msg = msg; @@ -601,7 +601,9 @@ public class OutboundClientMessageOneShotJob extends JobImpl { _replyTimeout = timeout; _timeoutMs = timeoutMs; } + public String getName() { return "Dispatch outbound client message"; } + public void runJob() { if (_selector != null) getContext().messageRegistry().registerPending(_selector, _replyFound, _replyTimeout, _timeoutMs); @@ -658,7 +660,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl { } public int hashCode() { - return sh.hashCode() + dh.hashCode(); + return sh.hashCode() ^ dh.hashCode(); } public boolean equals(Object o) { @@ -949,7 +951,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { * */ private class ReplySelector implements MessageSelector { - private long _pendingToken; + private final long _pendingToken; + public ReplySelector(long token) { _pendingToken = token; if (_log.shouldLog(Log.INFO)) @@ -989,8 +992,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { * */ private class SendSuccessJob extends JobImpl implements ReplyJob { - private SessionKey _key; - private TagSetHandle _tags; + private final SessionKey _key; + private final TagSetHandle _tags; /** * Create a new success job that will be fired when the message encrypted with @@ -1004,6 +1007,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl { } public String getName() { return "Send client message successful"; } + public void runJob() { // do we leak tags here? if (_finished) return; @@ -1054,8 +1058,8 @@ public class OutboundClientMessageOneShotJob extends JobImpl { * */ private class SendTimeoutJob extends JobImpl { - private SessionKey _key; - private TagSetHandle _tags; + private final SessionKey _key; + private final TagSetHandle _tags; public SendTimeoutJob(RouterContext enclosingContext, SessionKey key, TagSetHandle tags) { super(enclosingContext); @@ -1064,6 +1068,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl { } public String getName() { return "Send client message timed out"; } + public void runJob() { if (_log.shouldLog(Log.INFO)) _log.info(OutboundClientMessageOneShotJob.this.getJobId() diff --git a/router/java/src/net/i2p/router/transport/udp/PacketHandler.java b/router/java/src/net/i2p/router/transport/udp/PacketHandler.java index 972632077..064fe4c40 100644 --- a/router/java/src/net/i2p/router/transport/udp/PacketHandler.java +++ b/router/java/src/net/i2p/router/transport/udp/PacketHandler.java @@ -126,11 +126,12 @@ class PacketHandler { private static final short NEW_PEER = 3; private class Handler implements Runnable { - private UDPPacketReader _reader; - public volatile int _state; + private final UDPPacketReader _reader; + // TODO comment out all uses of _state + public /* volatile */ int _state; + public Handler() { _reader = new UDPPacketReader(_context); - _state = 0; } public void run() { @@ -382,7 +383,6 @@ class PacketHandler { } else { if (_log.shouldLog(Log.WARN)) _log.warn("Invalid introduction packet received for inbound con, falling back: " + packet); - _state = 33; } } @@ -420,7 +420,6 @@ class PacketHandler { if (isValid) { if (_log.shouldLog(Log.INFO)) _log.info("Valid introduction packet received for outbound established con: " + packet); - _state = 37; packet.decrypt(state.getCipherKey()); handlePacket(reader, packet, null, state, null);