aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/lb_policy/pick_first
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-09-06 10:40:38 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-09-06 10:40:38 -0700
commitf655c85140986a4b1298b1a0820fe76d8b8c6409 (patch)
tree63e124379b7795cfbc201279b680668bd7d1ebd8 /src/core/ext/lb_policy/pick_first
parent79620aaa1052fd02539a36caa63cbe24a2087b0f (diff)
Add is_resolver bit to grpc_resolved_address.
Diffstat (limited to 'src/core/ext/lb_policy/pick_first')
-rw-r--r--src/core/ext/lb_policy/pick_first/pick_first.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/ext/lb_policy/pick_first/pick_first.c b/src/core/ext/lb_policy/pick_first/pick_first.c
index 9decf70692..858a53ae55 100644
--- a/src/core/ext/lb_policy/pick_first/pick_first.c
+++ b/src/core/ext/lb_policy/pick_first/pick_first.c
@@ -443,17 +443,26 @@ static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(args->addresses != NULL);
GPR_ASSERT(args->client_channel_factory != NULL);
- if (args->addresses->naddrs == 0) return NULL;
+ // Find the number of backend addresses. We ignore balancer
+ // addresses, since we don't know how to handle them.
+ size_t num_addrs = 0;
+ for (size_t i = 0; i < args->addresses->naddrs; i++) {
+ if (!args->addresses->addrs[i].is_balancer) ++num_addrs;
+ }
+ if (num_addrs == 0) return NULL;
pick_first_lb_policy *p = gpr_malloc(sizeof(*p));
memset(p, 0, sizeof(*p));
p->subchannels =
- gpr_malloc(sizeof(grpc_subchannel *) * args->addresses->naddrs);
- memset(p->subchannels, 0, sizeof(*p->subchannels) * args->addresses->naddrs);
+ gpr_malloc(sizeof(grpc_subchannel *) * num_addrs);
+ memset(p->subchannels, 0, sizeof(*p->subchannels) * num_addrs);
grpc_subchannel_args sc_args;
size_t subchannel_idx = 0;
for (size_t i = 0; i < args->addresses->naddrs; i++) {
+ // Skip balancer addresses, since we only know how to handle backends.
+ if (args->addresses->addrs[i].is_balancer) continue;
+
memset(&sc_args, 0, sizeof(grpc_subchannel_args));
sc_args.addr = (struct sockaddr *)(args->addresses->addrs[i].addr);
sc_args.addr_len = (size_t)args->addresses->addrs[i].len;