Merge pull request #20930 from ericgribkoff/replace_factory

Replace existing channel factory arg, if any
reviewable/pr20965/r1
Eric Gribkoff 5 years ago committed by GitHub
commit 49ad24905d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/core/ext/transport/chttp2/client/insecure/channel_create.cc
  2. 12
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc

@ -99,7 +99,9 @@ grpc_channel* grpc_insecure_channel_create(const char* target,
// Add channel arg containing the client channel factory.
gpr_once_init(&g_factory_once, FactoryInit);
grpc_arg arg = grpc_core::ClientChannelFactory::CreateChannelArg(g_factory);
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
const char* arg_to_remove = arg.key;
grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
args, &arg_to_remove, 1, &arg, 1);
// Create channel.
grpc_channel* channel = grpc_core::CreateChannel(target, new_args);
// Clean up.

@ -205,11 +205,13 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
// Add channel args containing the client channel factory and channel
// credentials.
gpr_once_init(&g_factory_once, FactoryInit);
grpc_arg args_to_add[] = {
grpc_core::ClientChannelFactory::CreateChannelArg(g_factory),
grpc_channel_credentials_to_arg(creds)};
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
grpc_arg channel_factory_arg =
grpc_core::ClientChannelFactory::CreateChannelArg(g_factory);
grpc_arg args_to_add[] = {channel_factory_arg,
grpc_channel_credentials_to_arg(creds)};
const char* arg_to_remove = channel_factory_arg.key;
grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
args, &arg_to_remove, 1, args_to_add, GPR_ARRAY_SIZE(args_to_add));
new_args = creds->update_arguments(new_args);
// Create channel.
channel = grpc_core::CreateChannel(target, new_args);

Loading…
Cancel
Save