[clangd] Fix race in Global CDB shutdown

I believe the atomic write can be reordered after the notify, and that
seems to be happening on mac m1: http://45.33.8.238/macm1/2654/step_8.txt
In practice maybe seq_cst is enough? But no reason not to lock here.

https://bugs.llvm.org/show_bug.cgi?id=48998
This commit is contained in:
Sam McCall 2021-02-02 15:20:18 +01:00
parent 9e5fc578f9
commit 6ac3fd9706
1 changed files with 5 additions and 1 deletions

View File

@ -34,6 +34,7 @@
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <mutex>
#include <string>
#include <tuple>
#include <vector>
@ -553,7 +554,10 @@ public:
}
~BroadcastThread() {
ShouldStop.store(true, std::memory_order_release);
{
std::lock_guard<std::mutex> Lock(Mu);
ShouldStop.store(true, std::memory_order_release);
}
CV.notify_all();
Thread.join();
}