Fix server shutdown ordering issue

pull/21239/head
Vijay Pai 5 years ago
parent 81299e2362
commit 55748facd8
  1. 14
      src/cpp/server/server_cc.cc

@ -1009,9 +1009,6 @@ Server::Server(
Server::~Server() {
{
grpc::internal::ReleasableMutexLock lock(&mu_);
if (callback_cq_ != nullptr) {
callback_cq_->Shutdown();
}
if (started_ && !shutdown_) {
lock.Unlock();
Shutdown();
@ -1020,6 +1017,10 @@ Server::~Server() {
for (const auto& value : sync_req_mgrs_) {
value->Shutdown();
}
if (callback_cq_ != nullptr) {
callback_cq_->Shutdown();
callback_cq_ = nullptr;
}
}
}
@ -1315,6 +1316,13 @@ void Server::ShutdownInternal(gpr_timespec deadline) {
&callback_reqs_mu_, [this] { return callback_reqs_outstanding_ == 0; });
}
// Shutdown the callback CQ. The CQ is owned by its own shutdown tag, so it
// will delete itself at true shutdown.
if (callback_cq_ != nullptr) {
callback_cq_->Shutdown();
callback_cq_ = nullptr;
}
// Drain the shutdown queue (if the previous call to AsyncNext() timed out
// and we didn't remove the tag from the queue yet)
while (shutdown_cq.Next(&tag, &ok)) {

Loading…
Cancel
Save