mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Synchronizing object packing
Synchronize object packing between the binary store and the network sender since we're having trouble with these two users of data overwriting each others work in progress.
This commit is contained in:
parent
ac004ab9cc
commit
e4c4c95340
@ -42,6 +42,8 @@ public abstract class BinaryDataSource {
|
||||
|
||||
private BackgroundBinaryWriter backgroundBinaryWriter;
|
||||
|
||||
public static final Object packSynchObject = new Object();
|
||||
|
||||
/**
|
||||
* Create a binary data source. These are used both to store data in binary
|
||||
* files, and possibly also to send data to other PAMguard instances over the network.
|
||||
@ -224,12 +226,14 @@ public abstract class BinaryDataSource {
|
||||
* Then pack the data
|
||||
*/
|
||||
BinaryObjectData data;
|
||||
synchronized (packSynchObject) {
|
||||
if (pamDataUnit instanceof BackgroundDataUnit) {
|
||||
data = getBackgroundBinaryWriter().packBackgroundData((BackgroundDataUnit) pamDataUnit);
|
||||
}
|
||||
else {
|
||||
data = getPackedData(pamDataUnit);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Then put it back to how it was a moment ago.
|
||||
*/
|
||||
|
@ -75,7 +75,10 @@ public class NetworkObjectPacker {
|
||||
BinaryDataSource binarySource = dataBlock.getBinaryDataSource();
|
||||
int dataType2 = dataBlock.getQuickId();
|
||||
|
||||
BinaryObjectData packedObject = binarySource.getPackedData(dataUnit);
|
||||
BinaryObjectData packedObject = null;
|
||||
synchronized (BinaryDataSource.packSynchObject) {
|
||||
packedObject = binarySource.getPackedData(dataUnit);
|
||||
}
|
||||
byte[] data = packedObject.getData();
|
||||
int duDataLength = data.length + 12;
|
||||
DataUnitBaseData baseData = dataUnit.getBasicData();
|
||||
|
Loading…
Reference in New Issue
Block a user