Do not call grpc_init() for per-call-completion-queues created by a C++

synchronous server
pull/10348/head
Sree Kuchibhotla 8 years ago
parent 0ce1bb03e3
commit 0633c4a8d7
  1. 26
      include/grpc++/impl/codegen/grpc_library.h
  2. 3
      src/cpp/common/completion_queue_cc.cc

@ -51,18 +51,26 @@ extern GrpcLibraryInterface* g_glip;
/// Classes that require gRPC to be initialized should inherit from this class.
class GrpcLibraryCodegen {
public:
GrpcLibraryCodegen() {
GPR_CODEGEN_ASSERT(g_glip &&
"gRPC library not initialized. See "
"grpc::internal::GrpcLibraryInitializer.");
g_glip->init();
GrpcLibraryCodegen(bool call_grpc_init = true) : grpc_init_called(false) {
if (call_grpc_init) {
GPR_CODEGEN_ASSERT(g_glip &&
"gRPC library not initialized. See "
"grpc::internal::GrpcLibraryInitializer.");
g_glip->init();
grpc_init_called = true;
}
}
virtual ~GrpcLibraryCodegen() {
GPR_CODEGEN_ASSERT(g_glip &&
"gRPC library not initialized. See "
"grpc::internal::GrpcLibraryInitializer.");
g_glip->shutdown();
if (grpc_init_called) {
GPR_CODEGEN_ASSERT(g_glip &&
"gRPC library not initialized. See "
"grpc::internal::GrpcLibraryInitializer.");
g_glip->shutdown();
}
}
private:
bool grpc_init_called;
};
} // namespace grpc

@ -43,7 +43,8 @@ namespace grpc {
static internal::GrpcLibraryInitializer g_gli_initializer;
CompletionQueue::CompletionQueue(grpc_completion_queue* take) : cq_(take) {
CompletionQueue::CompletionQueue(grpc_completion_queue* take)
: GrpcLibraryCodegen(false), cq_(take) {
InitialAvalanching();
}

Loading…
Cancel
Save