|
From: <fli...@li...> - 2026-07-31 22:29:53
|
unknown user pushed a commit to branch release/2024.1
in repository simgear.
The following commit(s) were added to refs/heads/release/2024.1 by this push:
new 6611ebac Fix a race in TS::isDirSyncing
6611ebac is described below
SF URL: http://sourceforge.net/p/flightgear/simgear/ci/6611ebac8246523bccf6970a46f92cab1c674e48/
Commit: 6611ebac8246523bccf6970a46f92cab1c674e48
Author: James Turner
Committer: James Turner
AuthorDate: Thu Jul 30 09:12:36 2026 +0100
Fix a race in TS::isDirSyncing
---
simgear/scene/tsync/terrasync.cxx | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/simgear/scene/tsync/terrasync.cxx b/simgear/scene/tsync/terrasync.cxx
index 65dc93c8..f3f1c24e 100644
--- a/simgear/scene/tsync/terrasync.cxx
+++ b/simgear/scene/tsync/terrasync.cxx
@@ -616,17 +616,23 @@ void SGTerraSync::WorkerThread::updateSyncSlot(SyncSlot &slot)
}
// whatever happened, we're done with this repository instance
- slot.busy = false;
- slot.repository.reset();
- slot.pendingKBytes = 0;
- slot.pendingExtractKBytes = 0;
- slot.currentItem = {};
+ {
+ std::lock_guard<std::mutex> g(_stateLock);
+ slot.busy = false;
+ slot.repository.reset();
+ slot.pendingKBytes = 0;
+ slot.pendingExtractKBytes = 0;
+ slot.currentItem = {};
+ }
}
// init and start sync of the next repository
if (!slot.queue.empty()) {
- slot.currentItem = slot.queue.front();
- slot.queue.pop_front();
+ {
+ std::lock_guard<std::mutex> g(_stateLock);
+ slot.currentItem = slot.queue.front();
+ slot.queue.pop_front();
+ }
SGPath path(_local_dir);
path.append(slot.currentItem._dir);
@@ -898,7 +904,10 @@ void SGTerraSync::WorkerThread::drainWaitingTiles()
SyncItem next = waitingTiles.pop_front();
const auto slot = syncSlotForType(next._type);
SG_LOG(SG_TERRASYNC, SG_DEBUG, "adding to _syncSlots slot=" << slot);
- _syncSlots[slot].queue.push_back(next);
+ {
+ std::lock_guard<std::mutex> g(_stateLock);
+ _syncSlots[slot].queue.push_back(next);
+ }
}
}
|