kadircet created this revision. kadircet added a reviewer: sammccall. Herald added subscribers: usaxena95, arphaman. kadircet requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D97366 Files: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp @@ -314,8 +314,14 @@ ~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(); }
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp @@ -314,8 +314,14 @@ ~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(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits