From 6510d47c8117d357dfaa289683aa5feca50d7c72 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 5 Dec 2016 14:16:20 -0800 Subject: [PATCH] gpr_atm isn't automatically initialized to 0. Thanks Obama. --- include/grpc++/impl/codegen/completion_queue.h | 5 ++++- src/cpp/common/completion_queue_cc.cc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 75e73ee1f44..944f2c39198 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -102,7 +102,7 @@ class CompletionQueue : private GrpcLibraryCodegen { /// instance. CompletionQueue() { cq_ = g_core_codegen_interface->grpc_completion_queue_create(nullptr); - RegisterAvalanching(); // reserve this for the future shutdown + InitialAvalanching(); // reserve this for the future shutdown } /// Wrap \a take, taking ownership of the instance. @@ -174,6 +174,9 @@ class CompletionQueue : private GrpcLibraryCodegen { /// been finalized. Note that we maintain the requirement that an avalanche /// registration must take place before CQ shutdown (which must be maintained /// elsehwere) + void InitialAvalanching() { + gpr_atm_rel_store(&avalanches_in_flight_, static_cast(1)); + } void RegisterAvalanching() { gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, static_cast(1)); diff --git a/src/cpp/common/completion_queue_cc.cc b/src/cpp/common/completion_queue_cc.cc index 558f47af842..418baac5b2b 100644 --- a/src/cpp/common/completion_queue_cc.cc +++ b/src/cpp/common/completion_queue_cc.cc @@ -44,7 +44,7 @@ namespace grpc { static internal::GrpcLibraryInitializer g_gli_initializer; CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) { - RegisterAvalanching(); + InitialAvalanching(); } void CompletionQueue::Shutdown() { CompleteAvalanching(); }