Remove unmatched grpc_init from *ChannelFromFd methods (#29434)

* Remove unmatched grpc_init from *ChannelFromFd methods

These unmatched grpc_init calls were preventing grpc_shutdown from
completing, which notably showed up in the only tests we have that
exercise these methods: `client_interceptors_end2end_tests.cc`.

These inits appear to be unnecessary, so I removed them. But if I've
missed some reason they're needed, an alternative is to find the right
place to add the corresponding `init_lib.shutdown();` call. I'm not sure
where that would be at this point.

See b/175634383

* Alternative: init & shutdown before calling any core library
pull/29437/head
AJ Heller 3 years ago committed by GitHub
parent b3ded99cd4
commit f12658cdcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/cpp/client/create_channel_posix.cc

@ -34,7 +34,7 @@ class ChannelArguments;
std::shared_ptr<Channel> CreateInsecureChannelFromFd(const std::string& target,
int fd) {
grpc::internal::GrpcLibrary init_lib;
internal::GrpcLibrary init_lib;
init_lib.init();
grpc_channel_credentials* creds = grpc_insecure_credentials_create();
auto channel = CreateChannelInternal(
@ -42,6 +42,8 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const std::string& target,
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>());
grpc_channel_credentials_release(creds);
// Channel also initializes gRPC, so we can decrement the init ref count here.
init_lib.shutdown();
return channel;
}
@ -57,6 +59,8 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>());
grpc_channel_credentials_release(creds);
// Channel also initializes gRPC, so we can decrement the init ref count here.
init_lib.shutdown();
return channel;
}
@ -67,7 +71,7 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
std::vector<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) {
grpc::internal::GrpcLibrary init_lib;
internal::GrpcLibrary init_lib;
init_lib.init();
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
@ -76,6 +80,8 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
"", grpc_channel_create_from_fd(target.c_str(), fd, creds, &channel_args),
std::move(interceptor_creators));
grpc_channel_credentials_release(creds);
// Channel also initializes gRPC, so we can decrement the init ref count here.
init_lib.shutdown();
return channel;
}

Loading…
Cancel
Save