Merge remote-tracking branch 'origin/master'

master
sky 2019-12-11 17:42:43 +08:00
commit 9aa72cdc91
2 changed files with 5 additions and 4 deletions

View File

@ -13,9 +13,10 @@ public class MessageBlock {
}
public void reset() {
int id = getId();
file.setMemory(baseOffset, size, (byte) 0x00);
putInt(0, id);
file.setMemory(mapAddress(64), getPayloadSize(), (byte) 0x00);
updateTimestamp();
putInt(12, 0);
putInt(16, 0);
}
public int getId() {

View File

@ -52,7 +52,7 @@ public class TabooIpcClientImpl implements TabooIpcClient {
public boolean readMessage(byte[] buf) {
if (!available) throw new IllegalStateException();
if (this.block.getInt(16) == 2) {
this.block.getBytes(64, buf, 0, (int) this.block.getPayloadSize());
this.block.getBytes(64, buf, 0, Math.min((int) this.block.getPayloadSize(), buf.length));
return this.block.compareAndSwapInt(16, 2, 0);
} else return false;
}