aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/client_config/resolvers
diff options
context:
space:
mode:
authorGravatar Hongwei Wang <hongweiw@google.com>2015-08-03 12:29:18 -0700
committerGravatar Hongwei Wang <hongweiw@google.com>2015-08-03 12:29:18 -0700
commit72538b9103cb6c7d841ecfee2aa071609b3d322b (patch)
treed45cce9ba12cabcdb7b7a4e2f861032cd24ddb25 /src/core/client_config/resolvers
parenteace1904de2cefef8cd32ba2439a518b961a1061 (diff)
parentbee7b68b54ae379b89424fd207dfa47ec68f87a7 (diff)
Merge branch 'master' of https://github.com/grpc/grpc into zookeeper
Diffstat (limited to 'src/core/client_config/resolvers')
-rw-r--r--src/core/client_config/resolvers/dns_resolver.c16
1 files changed, 15 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;
}