diff --git a/apps/sam/java/src/net/i2p/sam/SAMStreamSession.java b/apps/sam/java/src/net/i2p/sam/SAMStreamSession.java index e5f0d10600..ce9ca8ed82 100644 --- a/apps/sam/java/src/net/i2p/sam/SAMStreamSession.java +++ b/apps/sam/java/src/net/i2p/sam/SAMStreamSession.java @@ -205,7 +205,8 @@ public class SAMStreamSession { SAMStreamSessionSocketHandler handler = getSocketHandler(id); if (handler == null) { - _log.error("Trying to send bytes through inexistent handler " +id); + if (_log.shouldLog(Log.WARN)) + _log.error("Trying to send bytes through inexistent handler " +id); // even though it failed, we need to read those bytes! for (int i = 0; i < size; i++) { int c = in.read(); @@ -482,12 +483,30 @@ public class SAMStreamSession { byte buf[] = ba.getData(); while (remaining > 0) { int read = in.read(buf, 0, remaining > buf.length ? buf.length : remaining); - if (read == -1) + if (read == -1) { throw new IOException("Insufficient data from the SAM client (" + remaining + "/" + size + ")"); - else if (read > 0) - i2pSocketOS.write(buf, 0, read); - - remaining -= read; + } else if (read > 0) { + remaining -= read; + try { + i2pSocketOS.write(buf, 0, read); + } catch (IOException ioe) { + // ok, the stream failed, but the SAM client didn't + if (_log.shouldLog(Log.WARN)) + _log.warn("Stream failed", ioe); + + removeSocketHandler(id); + + // emtpy the remaining payload so we can continue + for (int i = remaining; i > 0; i--) { + int c = in.read(); + if (c == -1) + throw new IOException("Stream closed, but the SAM client didn't send enough anyway (" + + i + " remaining)"); + } + + return false; + } + } } } finally { cache.release(ba); diff --git a/core/java/src/net/i2p/client/I2CPMessageProducer.java b/core/java/src/net/i2p/client/I2CPMessageProducer.java index c9b16177c8..fa9bf6319d 100644 --- a/core/java/src/net/i2p/client/I2CPMessageProducer.java +++ b/core/java/src/net/i2p/client/I2CPMessageProducer.java @@ -67,6 +67,7 @@ class I2CPMessageProducer { * */ public void disconnect(I2PSessionImpl session) throws I2PSessionException { + if (session.isClosed()) return; DestroySessionMessage dmsg = new DestroySessionMessage(); dmsg.setSessionId(session.getSessionId()); session.sendMessage(dmsg); diff --git a/history.txt b/history.txt index 06d26312b6..426dc0f3d1 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,9 @@ -$Id: history.txt,v 1.97 2004/12/05 19:54:08 jrandom Exp $ +$Id: history.txt,v 1.98 2004/12/05 21:08:03 jrandom Exp $ + +2004-12-06 jrandom + * Don't propogate streaming connection failures out to the SAM bridge as + fatal errors. + * Dont barf on repeated I2CP closure. 2004-12-05 jrandom * Explicitly use "127.0.0.1" to bind the I2CP listener, not the JVM's diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 884f9a6e02..9683ef1c8b 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.102 $ $Date: 2004/12/05 19:54:07 $"; + public final static String ID = "$Revision: 1.103 $ $Date: 2004/12/05 21:08:02 $"; public final static String VERSION = "0.4.2.2"; - public final static long BUILD = 6; + public final static long BUILD = 7; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION); System.out.println("Router ID: " + RouterVersion.ID);