HCOLL-167 added support for larger entry sizes

This commit is contained in:
Rob Austin
2014-10-24 14:54:17 +01:00
parent 59da12448e
commit cbe6253ca7
6 changed files with 67 additions and 73 deletions
@@ -94,17 +94,17 @@ class UdpReplicator extends UdpChannelReplicator implements Replica.Modification
final int bytesRead = in.position();
if (bytesRead < SIZE_OF_SHORT + SIZE_OF_SHORT)
if (bytesRead < SIZE_OF_SIZE + SIZE_OF_SIZE)
return;
out.limit(in.position());
final short invertedSize = out.readShort();
final int size = out.readUnsignedShort();
final int invertedSize = out.readInt();
final int size = out.readInt();
// check the the first 4 bytes are the inverted len followed by the len
// we do this to check that this is a valid start of entry, otherwise we throw it away
if (((short) ~size) != invertedSize)
if ( ~size != invertedSize)
return;
if (out.remaining() != size)
@@ -157,7 +157,7 @@ class UdpReplicator extends UdpChannelReplicator implements Replica.Modification
out.clear();
in.clear();
in.skip(SIZE_OF_SHORT);
in.skip(SIZE_OF_SIZE);
final boolean wasDataRead = modificationIterator.nextEntry(entryCallback, 0);
@@ -167,7 +167,7 @@ class UdpReplicator extends UdpChannelReplicator implements Replica.Modification
}
// we'll write the size inverted at the start
in.writeShort(0, ~(in.readUnsignedShort(SIZE_OF_SHORT)));
in.writeShort(0, ~(in.readUnsignedShort(SIZE_OF_SIZE)));
out.limit((int) in.position());
return socketChannel.write(out);