Merge pull request #17691 from mehrdada/fix-grpclibrary-initialization

Fix CoreCodegen initialization (destruction) bug
pull/17698/head
Vijay Pai 6 years ago committed by GitHub
commit 4ed3738d42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      include/grpcpp/impl/grpc_library.h

@ -35,18 +35,17 @@ class GrpcLibrary final : public GrpcLibraryInterface {
void shutdown() override { grpc_shutdown(); }
};
static GrpcLibrary g_gli;
static CoreCodegen g_core_codegen;
/// Instantiating this class ensures the proper initialization of gRPC.
class GrpcLibraryInitializer final {
public:
GrpcLibraryInitializer() {
if (grpc::g_glip == nullptr) {
grpc::g_glip = &g_gli;
static auto* const g_gli = new GrpcLibrary();
grpc::g_glip = g_gli;
}
if (grpc::g_core_codegen_interface == nullptr) {
grpc::g_core_codegen_interface = &g_core_codegen;
static auto* const g_core_codegen = new CoreCodegen();
grpc::g_core_codegen_interface = g_core_codegen;
}
}

Loading…
Cancel
Save