From b019d61f9a289e2f2f9323b55e4734f612649571 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Mon, 17 Oct 2016 13:23:51 -0700
Subject: [PATCH] Fix benchmark shutdown

---
 test/cpp/qps/server_async.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 082b4bc72f..191c6566ad 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -132,8 +132,11 @@ class AsyncQpsServerTest : public Server {
       (*ss)->shutdown = true;
     }
     // TODO (vpai): Remove this deadline and allow Shutdown to finish properly
-    auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(3);
-    server_->Shutdown(deadline);
+    std::thread shutdown_thread([this]() {
+      auto deadline =
+          std::chrono::system_clock::now() + std::chrono::seconds(3);
+      server_->Shutdown(deadline);
+    });
     for (auto cq = srv_cqs_.begin(); cq != srv_cqs_.end(); ++cq) {
       (*cq)->Shutdown();
     }
@@ -146,6 +149,7 @@ class AsyncQpsServerTest : public Server {
       while ((*cq)->Next(&got_tag, &ok))
         ;
     }
+    shutdown_thread.join();
   }
 
  private:
-- 
GitLab