Browse Source

Fix rare race in SyncRequestThreadManager shutdown

Vijay Pai 4 years ago
parent
commit
a8f19e9600
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/cpp/server/server_cc.cc

+ 6 - 0
src/cpp/server/server_cc.cc

@@ -1266,6 +1266,12 @@ void Server::ShutdownInternal(gpr_timespec deadline) {
     value->Shutdown();  // ThreadManager's Shutdown()
   }
 
+  // In case any calls were started in the sync request managers while they were
+  // still in the process of shutting down, do another round of cancellations.
+  // None of these should be matched since the accept_streams have already been
+  // shutdown, but their existence could still tie up a CQ waiting for a match.
+  grpc_server_cancel_all_calls(server_);
+
   // Wait for threads in all ThreadManagers to terminate
   for (const auto& value : sync_req_mgrs_) {
     value->Wait();