diff options
author | 2015-07-29 18:47:35 -0700 | |
---|---|---|
committer | 2015-07-29 18:47:35 -0700 | |
commit | 6b9f5c648803bcfd242c16600423cfc983966353 (patch) | |
tree | 3589da6d2b957bb1180c0529383414394cfcc214 /src/core/client_config | |
parent | 83f4d4e2187892294a46bc31c1e8d27def2ee481 (diff) |
Provide default host name
Diffstat (limited to 'src/core/client_config')
-rw-r--r-- | src/core/client_config/resolvers/dns_resolver.c | 16 | ||||
-rw-r--r-- | src/core/client_config/subchannel_factory_decorators/merge_channel_args.c | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/core/client_config/resolvers/dns_resolver.c b/src/core/client_config/resolvers/dns_resolver.c index ac401bc4d3..827b1a2be5 100644 --- a/src/core/client_config/resolvers/dns_resolver.c +++ b/src/core/client_config/resolvers/dns_resolver.c @@ -36,9 +36,11 @@ #include <string.h> #include <grpc/support/alloc.h> +#include <grpc/support/host_port.h> #include <grpc/support/string_util.h> #include "src/core/client_config/lb_policies/pick_first.h" +#include "src/core/client_config/subchannel_factory_decorators/add_channel_arg.h" #include "src/core/iomgr/resolve_address.h" #include "src/core/support/string.h" @@ -201,6 +203,9 @@ static grpc_resolver *dns_create( grpc_subchannel_factory *subchannel_factory) { dns_resolver *r; const char *path = uri->path; + grpc_arg default_host_arg; + char *host; + char *port; if (0 != strcmp(uri->authority, "")) { gpr_log(GPR_ERROR, "authority based uri's not supported"); @@ -209,6 +214,16 @@ static grpc_resolver *dns_create( if (path[0] == '/') ++path; + gpr_split_host_port(path, &host, &port); + + default_host_arg.type = GRPC_ARG_STRING; + default_host_arg.key = GRPC_ARG_DEFAULT_AUTHORITY; + default_host_arg.value.string = host; + subchannel_factory = grpc_subchannel_factory_add_channel_arg(subchannel_factory, &default_host_arg); + + gpr_free(host); + gpr_free(port); + r = gpr_malloc(sizeof(dns_resolver)); memset(r, 0, sizeof(*r)); gpr_ref_init(&r->refs, 1); @@ -218,7 +233,6 @@ static grpc_resolver *dns_create( r->default_port = gpr_strdup(default_port); r->subchannel_factory = subchannel_factory; r->lb_policy_factory = lb_policy_factory; - grpc_subchannel_factory_ref(subchannel_factory); return &r->base; } diff --git a/src/core/client_config/subchannel_factory_decorators/merge_channel_args.c b/src/core/client_config/subchannel_factory_decorators/merge_channel_args.c index 17e89d6d4d..7e028857ac 100644 --- a/src/core/client_config/subchannel_factory_decorators/merge_channel_args.c +++ b/src/core/client_config/subchannel_factory_decorators/merge_channel_args.c @@ -62,6 +62,7 @@ static grpc_subchannel *merge_args_factory_create_subchannel( grpc_channel_args *final_args = grpc_channel_args_merge(args->args, f->merge_args); grpc_subchannel *s; + args->args = final_args; s = grpc_subchannel_factory_create_subchannel(f->wrapped, args); grpc_channel_args_destroy(final_args); return s; @@ -76,6 +77,7 @@ grpc_subchannel_factory *grpc_subchannel_factory_merge_channel_args( merge_args_factory *f = gpr_malloc(sizeof(*f)); f->base.vtable = &merge_args_factory_vtable; gpr_ref_init(&f->refs, 1); + grpc_subchannel_factory_ref(input); f->wrapped = input; f->merge_args = grpc_channel_args_copy(args); return &f->base; |