From 5f2e90e3aeb39c53f9b4e71cbf1af0f28f78d46a Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 27 Sep 2016 17:24:32 -0700 Subject: Populate server_name for sockaddr resolver --- src/core/ext/resolver/sockaddr/sockaddr_resolver.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/core/ext/resolver') diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 74d2015e5c..94366458f4 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -53,10 +53,10 @@ typedef struct { gpr_refcount refs; /** load balancing policy name */ char *lb_policy_name; - + /** the path component of the uri passed in */ + char *target_name; /** the addresses that we've 'resolved' */ grpc_lb_addresses *addresses; - /** mutex guarding the rest of the state */ gpr_mu mu; /** have we published? */ @@ -121,7 +121,8 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, if (r->next_completion != NULL && !r->published) { r->published = true; *r->target_result = grpc_resolver_result_create( - "", grpc_lb_addresses_copy(r->addresses, NULL /* user_data_copy */), + r->target_name, + grpc_lb_addresses_copy(r->addresses, NULL /* user_data_copy */), r->lb_policy_name, NULL); grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); r->next_completion = NULL; @@ -133,6 +134,7 @@ static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { gpr_mu_destroy(&r->mu); grpc_lb_addresses_destroy(r->addresses, NULL /* user_data_destroy */); gpr_free(r->lb_policy_name); + gpr_free(r->target_name); gpr_free(r); } @@ -220,10 +222,12 @@ static grpc_resolver *sockaddr_create( if (errors_found) break; } + r->target_name = gpr_dump_slice(path_slice, GPR_DUMP_ASCII); gpr_slice_buffer_destroy(&path_parts); gpr_slice_unref(path_slice); if (errors_found) { gpr_free(r->lb_policy_name); + gpr_free(r->target_name); grpc_lb_addresses_destroy(r->addresses, NULL /* user_data_destroy */); gpr_free(r); return NULL; -- cgit v1.2.3 From 0d366c983cba6db9ac7f83229e93a61678819313 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 28 Sep 2016 14:17:45 -0700 Subject: PR comments --- src/core/ext/resolver/sockaddr/sockaddr_resolver.c | 2 +- test/core/client_config/resolvers/sockaddr_resolver_test.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/core/ext/resolver') diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 94366458f4..f232e0460b 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -222,7 +222,7 @@ static grpc_resolver *sockaddr_create( if (errors_found) break; } - r->target_name = gpr_dump_slice(path_slice, GPR_DUMP_ASCII); + r->target_name = gpr_strdup(args->uri->path); gpr_slice_buffer_destroy(&path_parts); gpr_slice_unref(path_slice); if (errors_found) { diff --git a/test/core/client_config/resolvers/sockaddr_resolver_test.c b/test/core/client_config/resolvers/sockaddr_resolver_test.c index 3b66221f35..b5d96efa1d 100644 --- a/test/core/client_config/resolvers/sockaddr_resolver_test.c +++ b/test/core/client_config/resolvers/sockaddr_resolver_test.c @@ -70,16 +70,15 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) { on_resolution_arg on_res_arg; memset(&on_res_arg, 0, sizeof(on_res_arg)); - on_res_arg.expected_server_name = gpr_strdup(uri->path); + on_res_arg.expected_server_name = uri->path; grpc_closure *on_resolution = grpc_closure_create(on_resolution_cb, &on_res_arg); grpc_resolver_next(&exec_ctx, resolver, &on_res_arg.resolver_result, on_resolution); GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds"); - grpc_uri_destroy(uri); grpc_exec_ctx_finish(&exec_ctx); - gpr_free(on_res_arg.expected_server_name); + grpc_uri_destroy(uri); } static void test_fails(grpc_resolver_factory *factory, const char *string) { -- cgit v1.2.3