* make sure we send the close message even if the I2PSocket is closed directly (rather than the outputStream)

* only fail the session tags as a last resort for the last resend, rather than on every resend after the 1st
This commit is contained in:
jrandom
2004-11-21 04:11:35 +00:00
committed by zzz
parent 603bc99a2f
commit 2b21b97277
2 changed files with 10 additions and 5 deletions

View File

@ -758,8 +758,12 @@ public class Connection {
// in case things really suck, the other side may have lost thier // in case things really suck, the other side may have lost thier
// session tags (e.g. they restarted), so jump back to ElGamal. // session tags (e.g. they restarted), so jump back to ElGamal.
if ( (newWindowSize == 1) && (numSends > 2) ) int failTagsAt = _options.getMaxResends() - 1;
if ( (newWindowSize == 1) && (numSends == failTagsAt) ) {
if (_log.shouldLog(Log.WARN))
_log.warn("Optimistically failing tags at resend " + numSends);
_context.sessionKeyManager().failTags(_remotePeer.getPublicKey()); _context.sessionKeyManager().failTags(_remotePeer.getPublicKey());
}
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Resend packet " + _packet + " time " + numSends + _log.warn("Resend packet " + _packet + " time " + numSends +

View File

@ -19,12 +19,13 @@ public class I2PSocketFull implements I2PSocket {
} }
public void close() throws IOException { public void close() throws IOException {
if (_connection == null) return; Connection c = _connection;
if (_connection.getIsConnected()) { if (c == null) return;
OutputStream out = _connection.getOutputStream(); if (c.getIsConnected()) {
OutputStream out = c.getOutputStream();
if (out != null) if (out != null)
out.close(); out.close();
_connection.disconnect(true); c.disconnect(true);
} else { } else {
//throw new IOException("Not connected"); //throw new IOException("Not connected");
} }