From ecd971c0e5fd842d744854cc126db19cb5b21747 Mon Sep 17 00:00:00 2001 From: jrandom Date: Sat, 15 Jan 2005 21:03:14 +0000 Subject: [PATCH] 2005-01-15 jrandom * Caught a series of (previously unhandled) errors caused by requeueing messages that had timed out on the TCP transport (thanks mae^!) * Reduce the barrier to dropping session tags on streaming lib resends - every fourth send should drop the tags, forcing ElGamal encryption. This will help speed up the recovery after a disconnect, rather than the drop every fifth send. --- .../net/i2p/client/streaming/Connection.java | 2 +- history.txt | 10 ++- .../src/net/i2p/router/OutNetMessagePool.java | 11 ++-- .../src/net/i2p/router/RouterVersion.java | 4 +- .../i2p/router/transport/TransportImpl.java | 3 +- .../tcp/TCPConnectionEstablisher.java | 62 +++++++++++-------- 6 files changed, 55 insertions(+), 37 deletions(-) diff --git a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java index 3525ee428..7beb188d5 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java @@ -831,7 +831,7 @@ public class Connection { // in case things really suck, the other side may have lost thier // session tags (e.g. they restarted), so jump back to ElGamal. - int failTagsAt = _options.getMaxResends() - 1; + int failTagsAt = _options.getMaxResends() - 2; if ( (newWindowSize == 1) && (numSends == failTagsAt) ) { if (_log.shouldLog(Log.WARN)) _log.warn("Optimistically failing tags at resend " + numSends); diff --git a/history.txt b/history.txt index e9ee4a2c5..c760ac50f 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,12 @@ -$Id: history.txt,v 1.125 2005/01/05 19:17:53 jrandom Exp $ +$Id: history.txt,v 1.126 2005/01/06 15:59:13 jrandom Exp $ + +2005-01-15 jrandom + * Caught a series of (previously unhandled) errors caused by requeueing + messages that had timed out on the TCP transport (thanks mae^!) + * Reduce the barrier to dropping session tags on streaming lib resends - + every fourth send should drop the tags, forcing ElGamal encryption. This + will help speed up the recovery after a disconnect, rather than the drop + every fifth send. * 2005-01-06 0.4.2.6 released diff --git a/router/java/src/net/i2p/router/OutNetMessagePool.java b/router/java/src/net/i2p/router/OutNetMessagePool.java index 6bff628b6..8e057ff49 100644 --- a/router/java/src/net/i2p/router/OutNetMessagePool.java +++ b/router/java/src/net/i2p/router/OutNetMessagePool.java @@ -41,6 +41,12 @@ public class OutNetMessagePool { * */ public void add(OutNetMessage msg) { + boolean valid = validate(msg); + if (!valid) { + _context.messageRegistry().unregisterPending(msg); + return; + } + if (_log.shouldLog(Log.INFO)) _log.info("Adding outbound message to " + msg.getTarget().getIdentity().getHash().toBase64().substring(0,6) @@ -48,11 +54,6 @@ public class OutNetMessagePool { + " expiring on " + msg.getMessage().getMessageExpiration() + " of type " + msg.getMessageType()); - boolean valid = validate(msg); - if (!valid) { - _context.messageRegistry().unregisterPending(msg); - return; - } MessageSelector selector = msg.getReplySelector(); if (selector != null) { _context.messageRegistry().registerPending(msg); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 7306db684..92bfd8e52 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.130 $ $Date: 2005/01/05 19:17:54 $"; + public final static String ID = "$Revision: 1.131 $ $Date: 2005/01/06 15:59:13 $"; public final static String VERSION = "0.4.2.6"; - public final static long BUILD = 0; + public final static long BUILD = 1; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/transport/TransportImpl.java b/router/java/src/net/i2p/router/transport/TransportImpl.java index adf6cfe03..40a3b2feb 100644 --- a/router/java/src/net/i2p/router/transport/TransportImpl.java +++ b/router/java/src/net/i2p/router/transport/TransportImpl.java @@ -164,7 +164,8 @@ public abstract class TransportImpl implements Transport { _context.statManager().addRateData("transport.expiredOnQueueLifetime", lifetime, lifetime); if (allowRequeue) { - if ( (msg.getExpiration() <= 0) || (msg.getExpiration() > _context.clock().now()) ) { + if ( ( (msg.getExpiration() <= 0) || (msg.getExpiration() > _context.clock().now()) ) + && (msg.getMessage() != null) ) { // this may not be the last transport available - keep going _context.outNetMessagePool().add(msg); // don't discard the data yet! diff --git a/router/java/src/net/i2p/router/transport/tcp/TCPConnectionEstablisher.java b/router/java/src/net/i2p/router/transport/tcp/TCPConnectionEstablisher.java index 5a4430095..84b78f6a0 100644 --- a/router/java/src/net/i2p/router/transport/tcp/TCPConnectionEstablisher.java +++ b/router/java/src/net/i2p/router/transport/tcp/TCPConnectionEstablisher.java @@ -23,36 +23,44 @@ public class TCPConnectionEstablisher implements Runnable { public void run() { while (true) { - RouterInfo info = _transport.getNextPeer(); - if (info == null) { - try { Thread.sleep(5*1000); } catch (InterruptedException ie) {} - continue; - } - - ConnectionBuilder cb = new ConnectionBuilder(_context, _transport, info); - TCPConnection con = null; try { - con = cb.establishConnection(); + loop(); } catch (Exception e) { - _log.log(Log.CRIT, "Unhandled exception establishing a connection to " - + info.getIdentity().getHash().toBase64(), e); + _log.log(Log.CRIT, "wtf, establisher b0rked. send this stack trace to jrandom", e); } - if (con != null) { - _transport.connectionEstablished(con); - } else { - if (!_context.router().isAlive()) return; - _transport.addConnectionErrorMessage(cb.getError()); - Hash peer = info.getIdentity().getHash(); - _context.profileManager().commErrorOccurred(peer); - _context.shitlist().shitlistRouter(peer, "Unable to contact"); - _context.netDb().fail(peer); - } - - // this removes the _pending block on the address and - // identity we attempted to contact. if the peer changed - // identities, any additional _pending blocks will also have - // been cleared above with .connectionEstablished - _transport.establishmentComplete(info); } } + + private void loop() { + RouterInfo info = _transport.getNextPeer(); + if (info == null) { + try { Thread.sleep(5*1000); } catch (InterruptedException ie) {} + return; + } + + ConnectionBuilder cb = new ConnectionBuilder(_context, _transport, info); + TCPConnection con = null; + try { + con = cb.establishConnection(); + } catch (Exception e) { + _log.log(Log.CRIT, "Unhandled exception establishing a connection to " + + info.getIdentity().getHash().toBase64(), e); + } + if (con != null) { + _transport.connectionEstablished(con); + } else { + if (!_context.router().isAlive()) return; + _transport.addConnectionErrorMessage(cb.getError()); + Hash peer = info.getIdentity().getHash(); + _context.profileManager().commErrorOccurred(peer); + _context.shitlist().shitlistRouter(peer, "Unable to contact"); + _context.netDb().fail(peer); + } + + // this removes the _pending block on the address and + // identity we attempted to contact. if the peer changed + // identities, any additional _pending blocks will also have + // been cleared above with .connectionEstablished + _transport.establishmentComplete(info); + } }