Skip to content

Commit

Permalink
gpr_atm isn't automatically initialized to 0. Thanks Obama.
Browse files Browse the repository at this point in the history
  • Loading branch information
vjpai committed Dec 5, 2016
1 parent bf24dd9 commit 6510d47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion include/grpc++/impl/codegen/completion_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<gpr_atm>(1));
}
void RegisterAvalanching() {
gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_,
static_cast<gpr_atm>(1));
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/common/completion_queue_cc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down

0 comments on commit 6510d47

Please sign in to comment.