File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -501,6 +501,8 @@ class PreambleThread {
501501 }
502502
503503 {
504+ // Add a lock guard to protect the critical section.
505+ std::lock_guard<std::mutex> Lock (Mutex);
504506 WithContext Guard (std::move (CurrentReq->Ctx ));
505507 // Note that we don't make use of the ContextProvider here.
506508 // Preamble tasks are always scheduled by ASTWorker tasks, and we
@@ -1329,6 +1331,8 @@ void ASTWorker::startTask(llvm::StringRef Name,
13291331 std::optional<UpdateType> Update,
13301332 TUScheduler::ASTActionInvalidation Invalidation) {
13311333 if (RunSync) {
1334+ // Add a lock guard to protect the critical section.
1335+ std::lock_guard<std::mutex> Lock (Mutex);
13321336 assert (!Done && " running a task after stop()" );
13331337 runTask (Name, Task);
13341338 return ;
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ bool BackgroundIndexRebuilder::enoughTUsToRebuild() const {
3434
3535void BackgroundIndexRebuilder::indexedTU () {
3636 maybeRebuild (" after indexing enough files" , [this ] {
37+ // Add a lock guard to protect the critical section
38+ std::lock_guard<std::mutex> Lock (Mu);
3739 ++IndexedTUs;
3840 if (Loading)
3941 return false ; // rebuild once loading finishes
@@ -64,6 +66,8 @@ void BackgroundIndexRebuilder::loadedShard(size_t ShardCount) {
6466}
6567void BackgroundIndexRebuilder::doneLoading () {
6668 maybeRebuild (" after loading index from disk" , [this ] {
69+ // Add a lock guard to protect the critical section.
70+ std::lock_guard<std::mutex> Lock (Mu);
6771 assert (Loading);
6872 --Loading;
6973 if (Loading) // was loading multiple batches concurrently
You can’t perform that action at this time.
0 commit comments