forked from I2P_Developers/i2p.i2p
SSU:
- Fix IB ACKBitfield.highestReceived() - More efficient OMS.acked() - Log tweaks
This commit is contained in:
@@ -177,7 +177,7 @@ class ACKSender implements Runnable {
|
||||
ack.setMessageType(PacketBuilder.TYPE_ACK);
|
||||
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Sending ACK for " + ackBitfields);
|
||||
_log.info("Sending " + ackBitfields + " to " + peer);
|
||||
// locking issues, we ignore the result, and acks are small,
|
||||
// so don't even bother allocating
|
||||
//peer.allocateSendingBytes(ack.getPacket().getLength(), true);
|
||||
|
@@ -151,7 +151,8 @@ class OutboundMessageState implements CDPQEntry {
|
||||
*/
|
||||
public synchronized boolean acked(ACKBitfield bitfield) {
|
||||
// stupid brute force, but the cardinality should be trivial
|
||||
for (int i = 0; i < bitfield.fragmentCount() && i < _numFragments; i++) {
|
||||
int highest = bitfield.highestReceived();
|
||||
for (int i = 0; i <= highest && i < _numFragments; i++) {
|
||||
if (bitfield.received(i))
|
||||
_fragmentAcks &= ~mask(i);
|
||||
}
|
||||
|
@@ -1089,7 +1089,7 @@ class PeerState {
|
||||
return _msgId == ((ACKBitfield)o).getMessageId();
|
||||
}
|
||||
@Override
|
||||
public String toString() { return "Full ACK of " + _msgId; }
|
||||
public String toString() { return "Full ACK " + _msgId; }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -558,19 +558,17 @@ class UDPPacketReader {
|
||||
*/
|
||||
public int highestReceived() {
|
||||
int count = fragmentCount();
|
||||
int rv = -1;
|
||||
for (int i = 0; i < _bitfieldSize; i++) {
|
||||
for (int i = _bitfieldSize - 1; i >= 0; i--) {
|
||||
byte b = _message[_bitfieldStart + i];
|
||||
b &= 0x7f;
|
||||
int j = 0;
|
||||
while (b != 0 && j++ < 7) {
|
||||
if ((b & 0x01) != 0)
|
||||
rv = (7 * i) + j;
|
||||
b >>= 1;
|
||||
b &= 0x7f;
|
||||
if ((b & 0x7f) == 0)
|
||||
continue;
|
||||
for (int j = 6; j >= 0; j--) {
|
||||
if ((b & 0x40) != 0)
|
||||
return (7 * i) + j;
|
||||
b <<= 1;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean received(int fragmentNum) {
|
||||
|
Reference in New Issue
Block a user