|
From: <fli...@li...> - 2026-08-03 11:13:01
|
unknown user pushed a commit to branch next
in repository simgear.
The following commit(s) were added to refs/heads/next by this push:
new a14dd266 Fix a race in TS::isDirSyncing
a14dd266 is described below
SF URL: http://sourceforge.net/p/flightgear/simgear/ci/a14dd266526ef13b39110e58e888a0d101dace1e/
Commit: a14dd266526ef13b39110e58e888a0d101dace1e
Author: James Turner
Committer: James Turner
AuthorDate: Thu Jul 30 11:55:06 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 0d6e646a..8dabe062 100644
--- a/simgear/scene/tsync/terrasync.cxx
+++ b/simgear/scene/tsync/terrasync.cxx
@@ -623,17 +623,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);
@@ -904,7 +910,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);
+ }
}
}
|