Sfoglia il codice sorgente

Fix rare race in SyncRequestThreadManager shutdown

Vijay Pai 4 anni fa
parent
commit
a8f19e9600
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  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();