diff options
author | Craig Tiller <ctiller@google.com> | 2015-08-19 10:15:44 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-08-19 10:15:44 -0700 |
commit | 9374ce819bff3c933f08b9512ded5c513527fd1f (patch) | |
tree | 023351155df64bfb02d13349443c156cfcae5068 /src/cpp | |
parent | 8f615526a300ce2a80de2d5a719f2bbab9a88382 (diff) |
Add comments, fix a subtle bug
Diffstat (limited to 'src/cpp')
-rw-r--r-- | src/cpp/server/server.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index b27aa32276..8b21337529 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -329,11 +329,15 @@ void Server::ShutdownInternal(gpr_timespec deadline) { shutdown_ = true; grpc_server_shutdown_and_notify(server_, cq_.cq(), new ShutdownRequest()); cq_.Shutdown(); + // Spin, eating requests until the completion queue is completely shutdown. + // If the deadline expires then cancel anything that's pending and keep + // spinning forever until the work is actually drained. SyncRequest* request; bool ok; while (SyncRequest::AsyncWait(&cq_, &request, &ok, deadline)) { if (request == NULL) { // deadline expired grpc_server_cancel_all_calls(server_); + deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); } else if (ok) { SyncRequest::CallData call_data(this, request); } |