[clangd] Destroy context before resetting CurrentReq
authorKadir Cetinkaya <kadircet@google.com>
Tue, 7 Apr 2020 19:07:44 +0000 (21:07 +0200)
committerKadir Cetinkaya <kadircet@google.com>
Wed, 8 Apr 2020 07:57:55 +0000 (09:57 +0200)
Summary:
Our tests stash callbacks into request context and rely on it being
invoked before threads going idle.

Reviewers: sammccall

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77671

clang-tools-extra/clangd/TUScheduler.cpp

index 46ec8e9..6b2d336 100644 (file)
@@ -255,9 +255,11 @@ public:
         NextReq.reset();
       }
 
-      WithContext Guard(std::move(CurrentReq->Ctx));
-      // Build the preamble and let the waiters know about it.
-      build(std::move(*CurrentReq));
+      {
+        WithContext Guard(std::move(CurrentReq->Ctx));
+        // Build the preamble and let the waiters know about it.
+        build(std::move(*CurrentReq));
+      }
       bool IsEmpty = false;
       {
         std::lock_guard<std::mutex> Lock(Mutex);