|
|
@ -320,18 +320,17 @@ static void pick_first_factory_ref(grpc_lb_policy_factory *factory) {} |
|
|
|
static void pick_first_factory_unref(grpc_lb_policy_factory *factory) {} |
|
|
|
static void pick_first_factory_unref(grpc_lb_policy_factory *factory) {} |
|
|
|
|
|
|
|
|
|
|
|
static grpc_lb_policy *create_pick_first(grpc_lb_policy_factory *factory, |
|
|
|
static grpc_lb_policy *create_pick_first(grpc_lb_policy_factory *factory, |
|
|
|
grpc_subchannel **subchannels, |
|
|
|
grpc_lb_policy_args *args) { |
|
|
|
size_t num_subchannels) { |
|
|
|
|
|
|
|
pick_first_lb_policy *p = gpr_malloc(sizeof(*p)); |
|
|
|
pick_first_lb_policy *p = gpr_malloc(sizeof(*p)); |
|
|
|
GPR_ASSERT(num_subchannels); |
|
|
|
GPR_ASSERT(args->num_subchannels > 0); |
|
|
|
memset(p, 0, sizeof(*p)); |
|
|
|
memset(p, 0, sizeof(*p)); |
|
|
|
grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable); |
|
|
|
grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable); |
|
|
|
p->subchannels = gpr_malloc(sizeof(grpc_subchannel *) * num_subchannels); |
|
|
|
p->subchannels = gpr_malloc(sizeof(grpc_subchannel *) * args->num_subchannels); |
|
|
|
p->num_subchannels = num_subchannels; |
|
|
|
p->num_subchannels = args->num_subchannels; |
|
|
|
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE, |
|
|
|
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE, |
|
|
|
"pick_first"); |
|
|
|
"pick_first"); |
|
|
|
memcpy(p->subchannels, subchannels, |
|
|
|
memcpy(p->subchannels, args->subchannels, |
|
|
|
sizeof(grpc_subchannel *) * num_subchannels); |
|
|
|
sizeof(grpc_subchannel *) * args->num_subchannels); |
|
|
|
grpc_iomgr_closure_init(&p->connectivity_changed, pf_connectivity_changed, p); |
|
|
|
grpc_iomgr_closure_init(&p->connectivity_changed, pf_connectivity_changed, p); |
|
|
|
gpr_mu_init(&p->mu); |
|
|
|
gpr_mu_init(&p->mu); |
|
|
|
return &p->base; |
|
|
|
return &p->base; |
|
|
|