From 06ca713df041572d5896135f2c806351a3584d0a Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 11 Feb 2020 13:54:25 -0800 Subject: [PATCH] Instantiate tracking members regardless of NDEBUG --- include/grpcpp/impl/codegen/completion_queue_impl.h | 11 ++++++----- include/grpcpp/server_impl.h | 5 ++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/grpcpp/impl/codegen/completion_queue_impl.h b/include/grpcpp/impl/codegen/completion_queue_impl.h index 41622f60900..502edfd9f15 100644 --- a/include/grpcpp/impl/codegen/completion_queue_impl.h +++ b/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -406,14 +406,15 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { return true; } -#ifndef NDEBUG - mutable grpc::internal::Mutex server_list_mutex_; - std::list server_list_ /* GUARDED_BY(server_list_mutex_) */; -#endif - grpc_completion_queue* cq_; // owned gpr_atm avalanches_in_flight_; + + // List of servers associated with this CQ. Even though this is only used with + // NDEBUG, instantiate it in all cases since otherwise the size will be + // inconsistent. + mutable grpc::internal::Mutex server_list_mutex_; + std::list server_list_ /* GUARDED_BY(server_list_mutex_) */; }; /// A specific type of completion queue used by the processing of notifications diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h index bcc4e3b45c9..8572c74b075 100644 --- a/include/grpcpp/server_impl.h +++ b/include/grpcpp/server_impl.h @@ -386,11 +386,10 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { // It is protected by mu_ CompletionQueue* callback_cq_ = nullptr; -#ifndef NDEBUG // List of CQs passed in by user that must be Shutdown only after Server is - // Shutdown. + // Shutdown. Even though this is only used with NDEBUG, instantiate it in all + // cases since otherwise the size will be inconsistent. std::vector cq_list_; -#endif }; } // namespace grpc_impl