diff options
author | Vijay Pai <vpai@google.com> | 2016-12-05 13:56:29 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2016-12-05 13:56:29 -0800 |
commit | cbe159925005d6f71e891792d593b51263ac6b76 (patch) | |
tree | ef98da31cf38c4b503b688b54accfc705a8b9bfb /src/cpp/common | |
parent | 9c6b5951af903dc0ec18f32fcdc15f85fc55f1e1 (diff) |
Track requests that could cause other requests to be created, and don't do
a real core shutdown of a CQ until such requests are done
Diffstat (limited to 'src/cpp/common')
-rw-r--r-- | src/cpp/common/completion_queue_cc.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc index 00cc102f92..558f47af84 100644 --- a/src/cpp/common/completion_queue_cc.cc +++ b/src/cpp/common/completion_queue_cc.cc @@ -43,11 +43,18 @@ namespace grpc { static internal::GrpcLibraryInitializer g_gli_initializer; -CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) {} +CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) { + RegisterAvalanching(); +} + +void CompletionQueue::Shutdown() { CompleteAvalanching(); } -void CompletionQueue::Shutdown() { - g_gli_initializer.summon(); - grpc_completion_queue_shutdown(cq_); +void CompletionQueue::CompleteAvalanching() { + // Check if this was the last avalanching operation + if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast<gpr_atm>(-1)) == 1) { + grpc_completion_queue_shutdown(cq_); + } } CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( |