From 6622c94c17b50acaa5b56451b304c0b6baad755b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 30 Jan 2020 09:25:57 -0800 Subject: [PATCH] Shutdown server properly before CQs --- test/cpp/qps/server_async.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 9c405bd3775..b6cb020a891 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -162,7 +162,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { std::lock_guard lock((*ss)->mutex); (*ss)->shutdown = true; } - std::thread shutdown_thread(&AsyncQpsServerTest::ShutdownThreadFunc, this); + // TODO(vjpai): Remove the following deadline and allow full proper + // shutdown. + server_->Shutdown(std::chrono::system_clock::now() + + std::chrono::seconds(3)); for (auto cq = srv_cqs_.begin(); cq != srv_cqs_.end(); ++cq) { (*cq)->Shutdown(); } @@ -175,7 +178,6 @@ class AsyncQpsServerTest final : public grpc::testing::Server { while ((*cq)->Next(&got_tag, &ok)) ; } - shutdown_thread.join(); } int GetPollCount() override { @@ -192,12 +194,6 @@ class AsyncQpsServerTest final : public grpc::testing::Server { } private: - void ShutdownThreadFunc() { - // 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); - } - void ThreadFunc(int thread_idx) { // Wait until work is available or we are shutting down bool ok;