Skip to content

Commit 35f7955

Browse files
committed
[NFC] Avoid data race condition.
1 parent 22fdc57 commit 35f7955

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

clang-tools-extra/clangd/TUScheduler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ class PreambleThread {
501501
}
502502

503503
{
504+
std::unique_lock<std::mutex> Lock(Mutex);
504505
WithContext Guard(std::move(CurrentReq->Ctx));
505506
// Note that we don't make use of the ContextProvider here.
506507
// Preamble tasks are always scheduled by ASTWorker tasks, and we
@@ -1329,6 +1330,7 @@ void ASTWorker::startTask(llvm::StringRef Name,
13291330
std::optional<UpdateType> Update,
13301331
TUScheduler::ASTActionInvalidation Invalidation) {
13311332
if (RunSync) {
1333+
std::lock_guard<std::mutex> Lock(Mutex);
13321334
assert(!Done && "running a task after stop()");
13331335
runTask(Name, Task);
13341336
return;

0 commit comments

Comments
 (0)