aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/client
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-08-11 11:46:32 -0700
committerGravatar yang-g <yangg@google.com>2015-08-11 12:37:32 -0700
commit0c034a01d12753a06a3dbbe202430ff0485ab978 (patch)
tree91ceb79a19e7b3e4d2b240e036fb06c1a93f57d5 /src/cpp/client
parentabfa427d654529dec5ad0dad790f5bf7f991ac85 (diff)
client code clean up
Diffstat (limited to 'src/cpp/client')
-rw-r--r--src/cpp/client/channel.cc32
-rw-r--r--src/cpp/client/client_context.cc9
2 files changed, 19 insertions, 22 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index af7366eb01..93536ae367 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -61,19 +61,25 @@ 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_, context->propagate_from_call_,
- context->propagation_options_.c_bitmask(), cq->cq(),
- method.channel_tag(), context->raw_deadline())
- : grpc_channel_create_call(
- c_channel_, context->propagate_from_call_,
- context->propagation_options_.c_bitmask(), cq->cq(),
- method.name(), context->authority().empty()
- ? host_str
- : context->authority().c_str(),
- context->raw_deadline());
+ bool registered = method.channel_tag() && context->authority().empty();
+ grpc_call* c_call = NULL;
+ if (registered) {
+ c_call = grpc_channel_create_registered_call(
+ c_channel_, context->propagate_from_call_,
+ context->propagation_options_.c_bitmask(), cq->cq(),
+ method.channel_tag(), context->raw_deadline());
+ } else {
+ const char* host_str = NULL;
+ if (!context->authority().empty()) {
+ host_str = context->authority().c_str();
+ } else if (!host_.empty()) {
+ host_str = host_.c_str();
+ }
+ c_call = grpc_channel_create_call(c_channel_, context->propagate_from_call_,
+ context->propagation_options_.c_bitmask(),
+ cq->cq(), method.name(), host_str,
+ context->raw_deadline());
+ }
grpc_census_call_set_context(c_call, context->census_context());
GRPC_TIMER_MARK(GRPC_PTAG_CPP_CALL_CREATED, c_call);
context->set_call(c_call, shared_from_this());
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index 1ed2d38961..dd86e7b108 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -48,7 +48,6 @@ namespace grpc {
ClientContext::ClientContext()
: initial_metadata_received_(false),
call_(nullptr),
- cq_(nullptr),
deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)),
propagate_from_call_(nullptr) {}
@@ -56,14 +55,6 @@ ClientContext::~ClientContext() {
if (call_) {
grpc_call_destroy(call_);
}
- if (cq_) {
- // Drain cq_.
- grpc_completion_queue_shutdown(cq_);
- while (grpc_completion_queue_next(cq_, gpr_inf_future(GPR_CLOCK_REALTIME))
- .type != GRPC_QUEUE_SHUTDOWN)
- ;
- grpc_completion_queue_destroy(cq_);
- }
}
std::unique_ptr<ClientContext> ClientContext::FromServerContext(