mirror of
https://github.com/i2p/i2p.i2p.git
synced 2026-06-07 11:01:42 +00:00
* revamped locking to block on flush and close until all of the
packets through that point have been ACKed, throwing an InterruptedIOException if there was a writeTimeout or an IOException if the con failed * revamped the ack/nack field settings to ack as much as possible * handle some strange timeout/resend errors on connection * pass 1/2rtt as the packet 'optional delay' field, and use that to schedule the ack time (the 'last' messages in a window set the optional delay to 0, asking for immediate ack of all received) * increase the optional delay to 2 bytes (#ms to delay) * inject random failures and delays if configured to do so in PacketHandler.choke * fix up the window size adjustment (increment on ack, /= 2 on resend) * use the highest RTT in the new RTT calculation so that we fit more in (via SACK) * fix up the SACK handling (duh) * revise the resend time calculation
This commit is contained in:
@@ -90,17 +90,20 @@ public class MessageInputStream extends InputStream {
|
||||
*
|
||||
*/
|
||||
public long[] getNacks() {
|
||||
List ids = null;
|
||||
synchronized (_dataLock) {
|
||||
for (long i = _highestReadyBlockId + 1; i < _highestBlockId; i++) {
|
||||
Long l = new Long(i);
|
||||
if (_notYetReadyBlocks.containsKey(l)) {
|
||||
// ACK
|
||||
} else {
|
||||
if (ids == null)
|
||||
ids = new ArrayList(4);
|
||||
ids.add(l);
|
||||
}
|
||||
return locked_getNacks();
|
||||
}
|
||||
}
|
||||
private long[] locked_getNacks() {
|
||||
List ids = null;
|
||||
for (long i = _highestReadyBlockId + 1; i < _highestBlockId; i++) {
|
||||
Long l = new Long(i);
|
||||
if (_notYetReadyBlocks.containsKey(l)) {
|
||||
// ACK
|
||||
} else {
|
||||
if (ids == null)
|
||||
ids = new ArrayList(4);
|
||||
ids.add(l);
|
||||
}
|
||||
}
|
||||
if (ids != null) {
|
||||
@@ -113,6 +116,13 @@ public class MessageInputStream extends InputStream {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAcks(PacketLocal packet) {
|
||||
synchronized (_dataLock) {
|
||||
packet.setAckThrough(_highestBlockId);
|
||||
packet.setNacks(locked_getNacks());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ascending list of block IDs greater than the highest
|
||||
* ready block ID, or null if there aren't any.
|
||||
|
||||
Reference in New Issue
Block a user