- Fix IB ACKBitfield.highestReceived()
- More efficient OMS.acked()
- Log tweaks
This commit is contained in:
zzz
2014-09-14 18:54:46 +00:00
parent 67fb4e7007
commit f248a33eaa
4 changed files with 12 additions and 13 deletions

View File

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

View File

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

View File

@@ -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; }
}
/**

View File

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