diff options
author | Garret Kelly <gdk@google.com> | 2017-06-07 16:25:36 -0400 |
---|---|---|
committer | Garret Kelly <gdk@google.com> | 2017-07-31 15:07:59 -0400 |
commit | 9663d0337ee7e53cf2029ae6dfd5d51a434b9b51 (patch) | |
tree | 6c9c80d64081e4a70d364b2fcc2fc68094ac1923 /src | |
parent | 4042e4c4d4b36891a2c220c8d5b69b9ad73a77bd (diff) |
Add a GrpcLibraryInitializer to client_context.cc
It's feasible that a program be written/linked such that it only use
ClientContext from grpc++, which could end up with the other instances
of GrpcLibraryInitializer not ending up in the final binary. Add a
GrpcLibraryInitializer to client_context.cc to ensure that the library
is initialized. The primary side-effect of the library not being
initialized when only using a ClientContext is that the destructor for
ClientContext indirectly ends up trying to call through
g_core_codegen_interface when destructing its metadata, which is null.
Diffstat (limited to 'src')
-rw-r--r-- | src/cpp/client/client_context.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 14cacc8f18..3af8bdc11a 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -24,6 +24,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include <grpc++/impl/grpc_library.h> #include <grpc++/security/credentials.h> #include <grpc++/server_context.h> #include <grpc++/support/time.h> @@ -38,6 +39,7 @@ class DefaultGlobalClientCallbacks final void Destructor(ClientContext* context) override {} }; +static internal::GrpcLibraryInitializer g_gli_initializer; static DefaultGlobalClientCallbacks g_default_client_callbacks; static ClientContext::GlobalCallbacks* g_client_callbacks = &g_default_client_callbacks; |