synchronized(receivedMessages) {
if(receivedMessages.contains(fragment.messageID, fragment.messageID)) continue;
}
PartiallyReceivedBuffer recvBuffer = receiveBuffers.get(fragment.messageID);
SparseBitmap recvMap = receiveMaps.get(fragment.messageID);
if(recvBuffer == null) {
if(logMINOR) Logger.minor(this, "Message id " + fragment.messageID + ": Creating buffer");
recvBuffer = new PartiallyReceivedBuffer(this);
if(fragment.firstFragment) {
if(!recvBuffer.setMessageLength(fragment.messageLength)) {
dontAck = true;
continue;
}
} else {
synchronized(receiveBufferSizeLock) {
if((receiveBufferUsed + fragment.fragmentLength) > MAX_RECEIVE_BUFFER_SIZE) {
if(logMINOR) Logger.minor(this, "Could not create buffer, would excede max size");
dontAck = true;
continue;
}
}
}
recvMap = new SparseBitmap();
receiveBuffers.put(fragment.messageID, recvBuffer);
receiveMaps.put(fragment.messageID, recvMap);
} else {
if(fragment.firstFragment) {
if(!recvBuffer.setMessageLength(fragment.messageLength)) {
dontAck = true;
continue;
}
}
}
if(!recvBuffer.add(fragment.fragmentData, fragment.fragmentOffset)) {
dontAck = true;
continue;
}
if(fragment.fragmentLength == 0) {
Logger.warning(this, "Received fragment of length 0");
continue;
}
recvMap.add(fragment.fragmentOffset, fragment.fragmentOffset + fragment.fragmentLength - 1);
if((recvBuffer.messageLength != -1) && recvMap.contains(0, recvBuffer.messageLength - 1)) {
receiveBuffers.remove(fragment.messageID);
receiveMaps.remove(fragment.messageID);
synchronized(receivedMessages) {
if(receivedMessages.contains(fragment.messageID, fragment.messageID)) continue;