diff options
author | Mark D. Roth <roth@google.com> | 2016-09-16 10:51:15 -0700 |
---|---|---|
committer | Mark D. Roth <roth@google.com> | 2016-09-16 10:51:15 -0700 |
commit | 8b7678cf846cc5b51cd4fc459c7a8d7a2aaebc01 (patch) | |
tree | 3c7981a52213e191da0fd31ad3e99149025d4778 /src/core/ext/resolver | |
parent | cf218fb7485644d1138d3b996752da05ae015926 (diff) | |
parent | 708d35fd2b54941d1741d3c9e6fc01fea91a30f3 (diff) |
Merge remote-tracking branch 'upstream/master' into http_connect
Diffstat (limited to 'src/core/ext/resolver')
-rw-r--r-- | src/core/ext/resolver/dns/native/dns_resolver.c | 11 | ||||
-rw-r--r-- | src/core/ext/resolver/sockaddr/sockaddr_resolver.c | 10 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/core/ext/resolver/dns/native/dns_resolver.c b/src/core/ext/resolver/dns/native/dns_resolver.c index 5886f6dcbf..a5697d6a2c 100644 --- a/src/core/ext/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/resolver/dns/native/dns_resolver.c @@ -178,11 +178,18 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_lb_policy_args lb_policy_args; memset(&lb_policy_args, 0, sizeof(lb_policy_args)); lb_policy_args.server_name = r->target_name; - lb_policy_args.addresses = addresses; + lb_policy_args.num_addresses = addresses->naddrs; + lb_policy_args.addresses = + gpr_malloc(sizeof(grpc_lb_address) * lb_policy_args.num_addresses); + memset(lb_policy_args.addresses, 0, + sizeof(grpc_lb_address) * lb_policy_args.num_addresses); + for (size_t i = 0; i < addresses->naddrs; ++i) { + lb_policy_args.addresses[i].resolved_address = &r->addresses->addrs[i]; + } lb_policy_args.client_channel_factory = r->client_channel_factory; lb_policy = grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args); - result = grpc_resolver_result_create(); + gpr_free(lb_policy_args.addresses); if (lb_policy != NULL) { grpc_resolver_result_set_lb_policy(result, lb_policy); GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction"); diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 146fbeb1d7..fe2e9bf8bf 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -126,10 +126,18 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy_args lb_policy_args; memset(&lb_policy_args, 0, sizeof(lb_policy_args)); lb_policy_args.server_name = ""; - lb_policy_args.addresses = r->addresses; + lb_policy_args.num_addresses = r->addresses->naddrs; + lb_policy_args.addresses = + gpr_malloc(sizeof(grpc_lb_address) * lb_policy_args.num_addresses); + memset(lb_policy_args.addresses, 0, + sizeof(grpc_lb_address) * lb_policy_args.num_addresses); + for (size_t i = 0; i < lb_policy_args.num_addresses; ++i) { + lb_policy_args.addresses[i].resolved_address = &r->addresses->addrs[i]; + } lb_policy_args.client_channel_factory = r->client_channel_factory; grpc_lb_policy *lb_policy = grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args); + gpr_free(lb_policy_args.addresses); grpc_resolver_result_set_lb_policy(result, lb_policy); GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "sockaddr"); r->published = 1; |