Fix ASAN failure
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index 6adabef..6bb88bc 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -221,9 +221,14 @@
MethodHandler::HandlerParameter(&call_, &ctx_, request_payload_));
global_callbacks->PostSynchronousRequest(&ctx_);
request_payload_ = nullptr;
- DummyTag ignored_tag;
+
cq_.Shutdown();
- /* Ensure the cq_ is shutdown (else this will hang indefinitely) */
+
+ CompletionQueueTag* op_tag = ctx_.GetCompletionOpTag();
+ cq_.TryPluck(op_tag, gpr_inf_future(GPR_CLOCK_REALTIME));
+
+ /* Ensure the cq_ is shutdown */
+ DummyTag ignored_tag;
GPR_ASSERT(cq_.Pluck(&ignored_tag) == false);
}
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index 05c05c8..01e9c00 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -166,6 +166,10 @@
call->PerformOps(completion_op_);
}
+CompletionQueueTag* ServerContext::GetCompletionOpTag() {
+ return static_cast<CompletionQueueTag*>(completion_op_);
+}
+
void ServerContext::AddInitialMetadata(const grpc::string& key,
const grpc::string& value) {
initial_metadata_.insert(std::make_pair(key, value));