mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:03:41 +02:00
lock our node while using it to prevent crash on domain shutdown
This commit is contained in:
parent
5cd0ecde18
commit
c3914e648f
1 changed files with 16 additions and 11 deletions
|
@ -27,11 +27,12 @@ bool VoxelSendThread::process() {
|
|||
uint64_t start = usecTimestampNow();
|
||||
|
||||
Node* node = NodeList::getInstance()->nodeWithUUID(_nodeUUID);
|
||||
VoxelNodeData* nodeData = NULL;
|
||||
|
||||
if (node) {
|
||||
node->lock(); // make sure the node list doesn't kill our node while we're using it
|
||||
VoxelNodeData* nodeData = NULL;
|
||||
|
||||
nodeData = (VoxelNodeData*) node->getLinkedData();
|
||||
}
|
||||
|
||||
int packetsSent = 0;
|
||||
|
||||
|
@ -44,6 +45,9 @@ bool VoxelSendThread::process() {
|
|||
packetsSent = deepestLevelVoxelDistributor(node, nodeData, viewFrustumChanged);
|
||||
}
|
||||
|
||||
node->unlock(); // we're done with this node for now.
|
||||
}
|
||||
|
||||
// dynamically sleep until we need to fire off the next set of voxels
|
||||
int elapsed = (usecTimestampNow() - start);
|
||||
int usecToSleep = VOXEL_SEND_INTERVAL_USECS - elapsed;
|
||||
|
@ -55,6 +59,7 @@ bool VoxelSendThread::process() {
|
|||
std::cout << "Last send took too much time, not sleeping!\n";
|
||||
}
|
||||
}
|
||||
|
||||
return isStillRunning(); // keep running till they terminate us
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue