Fix subchannel creation in pick_first and round_robin

pull/10247/head
Yuchen Zeng 8 years ago
parent 9f615de5ed
commit 3431996485
  1. 6
      src/core/ext/lb_policy/pick_first/pick_first.c
  2. 6
      src/core/ext/lb_policy/round_robin/round_robin.c

@ -423,11 +423,13 @@ static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx,
"This LB policy doesn't support user data. It will be ignored"); "This LB policy doesn't support user data. It will be ignored");
} }
static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS};
memset(&sc_args, 0, sizeof(grpc_subchannel_args)); memset(&sc_args, 0, sizeof(grpc_subchannel_args));
grpc_arg addr_arg = grpc_arg addr_arg =
grpc_create_subchannel_address_arg(&addresses->addresses[i].address); grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
grpc_channel_args *new_args = grpc_channel_args *new_args = grpc_channel_args_copy_and_add_and_remove(
grpc_channel_args_copy_and_add(args->args, &addr_arg, 1); args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &addr_arg,
1);
gpr_free(addr_arg.value.string); gpr_free(addr_arg.value.string);
sc_args.args = new_args; sc_args.args = new_args;
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel( grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(

@ -709,11 +709,13 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
/* Skip balancer addresses, since we only know how to handle backends. */ /* Skip balancer addresses, since we only know how to handle backends. */
if (addresses->addresses[i].is_balancer) continue; if (addresses->addresses[i].is_balancer) continue;
static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS};
memset(&sc_args, 0, sizeof(grpc_subchannel_args)); memset(&sc_args, 0, sizeof(grpc_subchannel_args));
grpc_arg addr_arg = grpc_arg addr_arg =
grpc_create_subchannel_address_arg(&addresses->addresses[i].address); grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
grpc_channel_args *new_args = grpc_channel_args *new_args = grpc_channel_args_copy_and_add_and_remove(
grpc_channel_args_copy_and_add(args->args, &addr_arg, 1); args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &addr_arg,
1);
gpr_free(addr_arg.value.string); gpr_free(addr_arg.value.string);
sc_args.args = new_args; sc_args.args = new_args;
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel( grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(

Loading…
Cancel
Save