2004-12-06 jrandom

* Don't propogate streaming connection failures out to the SAM bridge as
      fatal errors.
    * Dont barf on repeated I2CP closure.
This commit is contained in:
jrandom
2004-12-06 05:03:57 +00:00
committed by zzz
parent 2fba055696
commit e52d637092
4 changed files with 34 additions and 9 deletions

View File

@ -205,6 +205,7 @@ public class SAMStreamSession {
SAMStreamSessionSocketHandler handler = getSocketHandler(id);
if (handler == null) {
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++) {
@ -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);
} 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);

View File

@ -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);

View File

@ -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

View File

@ -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);