|
| 1 | +diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h |
| 2 | +index 80c7c41982..3f7d8a7714 100644 |
| 3 | +--- a/include/grpcpp/impl/codegen/completion_queue.h |
| 4 | ++++ b/include/grpcpp/impl/codegen/completion_queue.h |
| 5 | +@@ -32,6 +32,8 @@ |
| 6 | + #ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H |
| 7 | + #define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H |
| 8 | + |
| 9 | ++#include <typeinfo> |
| 10 | ++ |
| 11 | + #include <grpc/impl/codegen/atm.h> |
| 12 | + #include <grpcpp/impl/codegen/completion_queue_tag.h> |
| 13 | + #include <grpcpp/impl/codegen/core_codegen_interface.h> |
| 14 | +@@ -106,7 +108,9 @@ class CompletionQueue : private GrpcLibraryCodegen { |
| 15 | + |
| 16 | + /// Destructor. Destroys the owned wrapped completion queue / instance. |
| 17 | + ~CompletionQueue() { |
| 18 | +- g_core_codegen_interface->grpc_completion_queue_destroy(cq_); |
| 19 | ++ if (typeid(*g_core_codegen_interface).hash_code() != typeid(CoreCodegenInterface).hash_code()) { |
| 20 | ++ g_core_codegen_interface->grpc_completion_queue_destroy(cq_); |
| 21 | ++ } |
| 22 | + } |
| 23 | + |
| 24 | + /// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT. |
| 25 | +diff --git a/include/grpcpp/impl/codegen/grpc_library.h b/include/grpcpp/impl/codegen/grpc_library.h |
| 26 | +index 17c904d71a..a092b2204d 100644 |
| 27 | +--- a/include/grpcpp/impl/codegen/grpc_library.h |
| 28 | ++++ b/include/grpcpp/impl/codegen/grpc_library.h |
| 29 | +@@ -19,6 +19,8 @@ |
| 30 | + #ifndef GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H |
| 31 | + #define GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H |
| 32 | + |
| 33 | ++#include <typeinfo> |
| 34 | ++ |
| 35 | + #include <grpcpp/impl/codegen/core_codegen_interface.h> |
| 36 | + |
| 37 | + namespace grpc { |
| 38 | +@@ -47,7 +49,8 @@ class GrpcLibraryCodegen { |
| 39 | + } |
| 40 | + } |
| 41 | + virtual ~GrpcLibraryCodegen() { |
| 42 | +- if (grpc_init_called_) { |
| 43 | ++ if (grpc_init_called_ && |
| 44 | ++ typeid(*g_glip).hash_code() != typeid(GrpcLibraryInterface).hash_code()) { |
| 45 | + GPR_CODEGEN_ASSERT(g_glip && |
| 46 | + "gRPC library not initialized. See " |
| 47 | + "grpc::internal::GrpcLibraryInitializer."); |
0 commit comments