diff options
author | 2018-10-02 14:49:17 -0700 | |
---|---|---|
committer | 2018-10-02 14:49:17 -0700 | |
commit | 130eeeaeb9fa5eedb2c627791fc52e6d3a25834c (patch) | |
tree | 3c62cb9c3eb225e28a2ce4a62c0404f127419eba /src/cpp/client | |
parent | 1d999617e2ef67686d6f6d8be8e2dc62976380eb (diff) | |
parent | 35970109a13cc3cfb34ec6132e99c315dedcde1b (diff) |
Merge branch 'master' into interceptors_initial
Diffstat (limited to 'src/cpp/client')
-rw-r--r-- | src/cpp/client/channel_cc.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index c9f70b186f..2cab41b3f5 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -20,6 +20,7 @@ #include <chrono> #include <condition_variable> +#include <cstring> #include <memory> #include <mutex> @@ -72,6 +73,10 @@ Channel::~Channel() { namespace { +inline grpc_slice SliceFromArray(const char* arr, size_t len) { + return g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, len); +} + grpc::string GetChannelInfoField(grpc_channel* channel, grpc_channel_info* channel_info, char*** channel_info_field) { @@ -118,16 +123,17 @@ internal::Call Channel::CreateCall(const internal::RpcMethod& method, context->propagation_options_.c_bitmask(), cq->cq(), method.channel_tag(), context->raw_deadline(), nullptr); } else { - const char* host_str = nullptr; - if (!context->authority().empty()) { - host_str = context->authority_.c_str(); + const string* host_str = nullptr; + if (!context->authority_.empty()) { + host_str = &context->authority_; } else if (!host_.empty()) { - host_str = host_.c_str(); + host_str = &host_; } - grpc_slice method_slice = SliceFromCopiedString(method.name()); + grpc_slice method_slice = + SliceFromArray(method.name(), strlen(method.name())); grpc_slice host_slice; if (host_str != nullptr) { - host_slice = SliceFromCopiedString(host_str); + host_slice = SliceFromCopiedString(*host_str); } c_call = grpc_channel_create_call( c_channel_, context->propagate_from_call_, |