2005-02-27 jrandom

* Don't rerequest leaseSets if there are already pending requests
    * Reverted the insufficiently tested caching in the DSA/SHA1 impl, and
      temporary disabled the streaming lib packet caching.
    * Reduced the resend RTT penalty to 10s
This commit is contained in:
jrandom
2005-02-27 22:09:37 +00:00
committed by zzz
parent 7983bb1490
commit 469a0852d7
13 changed files with 219 additions and 322 deletions

View File

@ -188,7 +188,8 @@ public class Connection {
}
void ackImmediately() {
_receiver.send(null, 0, 0);
PacketLocal packet = _receiver.send(null, 0, 0);
//packet.releasePayload();
}
/**
@ -871,7 +872,7 @@ public class Connection {
+ ") for " + Connection.this.toString());
// setRTT has its own ceiling
getOptions().setRTT(getOptions().getRTT() + 30*1000);
getOptions().setRTT(getOptions().getRTT() + 10*1000);
getOptions().setWindowSize(newWindowSize);
windowAdjusted();
}

View File

@ -20,13 +20,11 @@ class ConnectionDataReceiver implements MessageOutputStream.DataReceiver {
private Log _log;
private Connection _connection;
private static final MessageOutputStream.WriteStatus _dummyStatus = new DummyStatus();
private ByteCache _cache;
public ConnectionDataReceiver(I2PAppContext ctx, Connection con) {
_context = ctx;
_log = ctx.logManager().getLog(ConnectionDataReceiver.class);
_connection = con;
_cache = ByteCache.getInstance(128, Packet.MAX_PAYLOAD_SIZE);
}
public boolean writeInProcess() {
@ -135,9 +133,11 @@ class ConnectionDataReceiver implements MessageOutputStream.DataReceiver {
}
private PacketLocal buildPacket(Connection con, byte buf[], int off, int size, boolean forceIncrement) {
if (size > Packet.MAX_PAYLOAD_SIZE) throw new IllegalArgumentException("size is too large (" + size + ")");
boolean ackOnly = isAckOnly(con, size);
PacketLocal packet = new PacketLocal(_context, con.getRemotePeer(), con);
ByteArray data = (size <= Packet.MAX_PAYLOAD_SIZE ? _cache.acquire() : new ByteArray(new byte[size]));
//ByteArray data = packet.acquirePayload();
ByteArray data = new ByteArray(new byte[size]);
if (size > 0)
System.arraycopy(buf, off, data.getData(), 0, size);
data.setValid(size);

View File

@ -18,11 +18,9 @@ import net.i2p.util.SimpleTimer;
public class ConnectionPacketHandler {
private I2PAppContext _context;
private Log _log;
private ByteCache _cache;
public ConnectionPacketHandler(I2PAppContext context) {
_context = context;
_cache = ByteCache.getInstance(128, Packet.MAX_PAYLOAD_SIZE);
_log = context.logManager().getLog(ConnectionPacketHandler.class);
_context.statManager().createRateStat("stream.con.receiveMessageSize", "Size of a message received on a connection", "Stream", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
_context.statManager().createRateStat("stream.con.receiveDuplicateSize", "Size of a duplicate message received on a connection", "Stream", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
@ -37,7 +35,7 @@ public class ConnectionPacketHandler {
if (!ok) {
if ( (!packet.isFlagSet(Packet.FLAG_RESET)) && (_log.shouldLog(Log.ERROR)) )
_log.error("Packet does NOT verify: " + packet);
_cache.release(packet.getPayload());
packet.releasePayload();
return;
}
@ -51,7 +49,7 @@ public class ConnectionPacketHandler {
if (_log.shouldLog(Log.WARN))
_log.warn("Received a packet after hard disconnect, ignoring: " + packet + " on " + con);
}
_cache.release(packet.getPayload());
packet.releasePayload();
return;
}
@ -156,9 +154,9 @@ public class ConnectionPacketHandler {
}
}
if (ackOnly) {
if (ackOnly || !isNew) {
// non-ack message payloads are queued in the MessageInputStream
_cache.release(packet.getPayload());
packet.releasePayload();
}
}
@ -220,7 +218,7 @@ public class ConnectionPacketHandler {
+ ") for " + con);
// setRTT has its own ceiling
con.getOptions().setRTT(con.getOptions().getRTT() + 30*1000);
con.getOptions().setRTT(con.getOptions().getRTT() + 10*1000);
con.getOptions().setWindowSize(oldSize);
congested = true;

View File

@ -219,10 +219,17 @@ public class Packet {
return (_payload == null ? 0 : _payload.getValid());
}
public void releasePayload() {
if (_payload != null)
_cache.release(_payload);
//if (_payload != null)
// _cache.release(_payload);
_payload = null;
}
public ByteArray acquirePayload() {
ByteArray old = _payload;
_payload = new ByteArray(new byte[Packet.MAX_PAYLOAD_SIZE]); //_cache.acquire();
//if (old != null)
// _cache.release(old);
return _payload;
}
/** is a particular flag set on this packet? */
public boolean isFlagSet(int flag) { return 0 != (_flags & flag); }