diff options
author | yang-g <yangg@google.com> | 2015-08-04 16:15:57 -0700 |
---|---|---|
committer | yang-g <yangg@google.com> | 2015-08-04 16:15:57 -0700 |
commit | 5239ee2bd0a035ad7ac94b259b318677869126ad (patch) | |
tree | bc7029f1bb5b55f39f0d08d93178b0f46f32d6f6 /src/cpp | |
parent | b335256444349361cf406b14bc846611b7249056 (diff) | |
parent | 702ea25c8f5d3b12e8db34483396b872cb6ea536 (diff) |
Merge remote-tracking branch 'upstream/master' into cancel
Diffstat (limited to 'src/cpp')
-rw-r--r-- | src/cpp/client/channel.cc | 12 | ||||
-rw-r--r-- | src/cpp/client/channel.h | 5 | ||||
-rw-r--r-- | src/cpp/client/create_channel.cc | 4 | ||||
-rw-r--r-- | src/cpp/client/insecure_credentials.cc | 2 | ||||
-rw-r--r-- | src/cpp/client/secure_credentials.cc | 3 |
5 files changed, 15 insertions, 11 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index 5df81e641e..ee143d68a0 100644 --- a/src/cpp/client/channel.cc +++ b/src/cpp/client/channel.cc @@ -51,13 +51,16 @@ namespace grpc { -Channel::Channel(const grpc::string& target, grpc_channel* channel) - : target_(target), c_channel_(channel) {} +Channel::Channel(grpc_channel* channel) : c_channel_(channel) {} + +Channel::Channel(const grpc::string& host, grpc_channel* channel) + : host_(host), c_channel_(channel) {} Channel::~Channel() { grpc_channel_destroy(c_channel_); } Call Channel::CreateCall(const RpcMethod& method, ClientContext* context, CompletionQueue* cq) { + const char* host_str = host_.empty() ? NULL : host_.c_str(); auto c_call = method.channel_tag() && context->authority().empty() ? grpc_channel_create_registered_call(c_channel_, cq->cq(), @@ -65,7 +68,7 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context, context->raw_deadline()) : grpc_channel_create_call(c_channel_, cq->cq(), method.name(), context->authority().empty() - ? target_.c_str() + ? host_str : context->authority().c_str(), context->raw_deadline()); grpc_census_call_set_context(c_call, context->census_context()); @@ -86,7 +89,8 @@ void Channel::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) { } void* Channel::RegisterMethod(const char* method) { - return grpc_channel_register_call(c_channel_, method, target_.c_str()); + return grpc_channel_register_call(c_channel_, method, + host_.empty() ? NULL : host_.c_str()); } } // namespace grpc diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h index 9108713c58..8660146856 100644 --- a/src/cpp/client/channel.h +++ b/src/cpp/client/channel.h @@ -52,7 +52,8 @@ class StreamContextInterface; class Channel GRPC_FINAL : public GrpcLibrary, public ChannelInterface { public: - Channel(const grpc::string& target, grpc_channel* c_channel); + explicit Channel(grpc_channel* c_channel); + Channel(const grpc::string& host, grpc_channel* c_channel); ~Channel() GRPC_OVERRIDE; virtual void* RegisterMethod(const char* method) GRPC_OVERRIDE; @@ -62,7 +63,7 @@ class Channel GRPC_FINAL : public GrpcLibrary, public ChannelInterface { Call* call) GRPC_OVERRIDE; private: - const grpc::string target_; + const grpc::string host_; grpc_channel* const c_channel_; // owned }; diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index dbe2694a78..21d01b739d 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -51,7 +51,7 @@ std::shared_ptr<ChannelInterface> CreateChannel( cp_args.SetString(GRPC_ARG_PRIMARY_USER_AGENT_STRING, user_agent_prefix.str()); return creds ? creds->CreateChannel(target, cp_args) - : std::shared_ptr<ChannelInterface>(new Channel( - target, grpc_lame_client_channel_create(NULL))); + : std::shared_ptr<ChannelInterface>( + new Channel(grpc_lame_client_channel_create(NULL))); } } // namespace grpc diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc index e802fa8034..d8dcaa1436 100644 --- a/src/cpp/client/insecure_credentials.cc +++ b/src/cpp/client/insecure_credentials.cc @@ -49,7 +49,7 @@ class InsecureCredentialsImpl GRPC_FINAL : public Credentials { grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); return std::shared_ptr<ChannelInterface>(new Channel( - target, grpc_insecure_channel_create(target.c_str(), &channel_args))); + grpc_insecure_channel_create(target.c_str(), &channel_args))); } // InsecureCredentials should not be applied to a call. diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index abf0cb387e..2d6114e06b 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -44,8 +44,7 @@ std::shared_ptr<grpc::ChannelInterface> SecureCredentials::CreateChannel( grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); return std::shared_ptr<ChannelInterface>(new Channel( - args.GetSslTargetNameOverride().empty() ? target - : args.GetSslTargetNameOverride(), + args.GetSslTargetNameOverride(), grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args))); } |