aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-03-18 15:53:28 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2016-03-18 15:53:28 -0700
commit146070db8db189a62112ae0b84de5d12ffc02f3a (patch)
tree43fa71729b4af02cb413f5daaf2f042eb010fe29
parenta643960d458020d43e9432cd75f60355cce13946 (diff)
fixed multiple initialization of globals
-rw-r--r--include/grpc++/impl/grpc_library.h8
-rw-r--r--src/cpp/client/secure_credentials.cc3
2 files changed, 7 insertions, 4 deletions
diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h
index d26f4a4cab..ecb5a4d64d 100644
--- a/include/grpc++/impl/grpc_library.h
+++ b/include/grpc++/impl/grpc_library.h
@@ -58,8 +58,12 @@ static CoreCodegen g_core_codegen;
class GrpcLibraryInitializer GRPC_FINAL {
public:
GrpcLibraryInitializer() {
- grpc::g_glip = &g_gli;
- grpc::g_core_codegen_interface = &g_core_codegen;
+ if (grpc::g_glip == nullptr) {
+ grpc::g_glip = &g_gli;
+ }
+ if (grpc::g_core_codegen_interface == nullptr) {
+ grpc::g_core_codegen_interface = &g_core_codegen;
+ }
}
/// A no-op method to force the linker to reference this class, which will
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index 308455527c..c34b840f90 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -60,8 +60,7 @@ std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannel(
SecureCallCredentials::SecureCallCredentials(grpc_call_credentials* c_creds)
: c_creds_(c_creds) {
- internal::GrpcLibraryInitializer gli_initializer;
- gli_initializer.summon();
+ g_gli_initializer.summon();
}
bool SecureCallCredentials::ApplyToCall(grpc_call* call) {