[clang-tools-extra] c94ecf3 - [clangd] Fix a race
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 24 03:15:22 PST 2021
Author: Kadir Cetinkaya
Date: 2021-02-24T12:15:16+01:00
New Revision: c94ecf3f81ca42a98b3b279a7b210b67715f1c41
URL: https://github.com/llvm/llvm-project/commit/c94ecf3f81ca42a98b3b279a7b210b67715f1c41
DIFF: https://github.com/llvm/llvm-project/commit/c94ecf3f81ca42a98b3b279a7b210b67715f1c41.diff
LOG: [clangd] Fix a race
Differential Revision: https://reviews.llvm.org/D97366
Added:
Modified:
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
index 4542f7423a48..695ed89ae7f4 100644
--- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -314,8 +314,14 @@ TEST_F(LSPTest, ModulesThreadingTest) {
~AsyncCounter() {
// Verify shutdown sequence was performed.
// Real modules would not do this, to be robust to no ClangdServer.
- EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown";
- EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle";
+ {
+ // We still need the lock here, as Queue might be empty when
+ // ClangdServer calls blockUntilIdle, but run() might not have returned
+ // yet.
+ std::lock_guard<std::mutex> Lock(Mu);
+ EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown";
+ EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle";
+ }
Thread.join();
}
More information about the cfe-commits
mailing list