aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/client/client_context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp/client/client_context.cc')
-rw-r--r--src/cpp/client/client_context.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index d5eb029a24..50da75f09c 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -87,10 +87,13 @@ void ClientContext::set_call(grpc_call* call,
call_ = call;
channel_ = channel;
if (creds_ && !creds_->ApplyToCall(call_)) {
+ // TODO(yashykt): should interceptors also see this status?
+ SendCancelToInterceptors();
grpc_call_cancel_with_status(call, GRPC_STATUS_CANCELLED,
"Failed to set credentials to rpc.", nullptr);
}
if (call_canceled_) {
+ SendCancelToInterceptors();
grpc_call_cancel(call_, nullptr);
}
}
@@ -111,16 +114,20 @@ void ClientContext::set_compression_algorithm(
void ClientContext::TryCancel() {
std::unique_lock<std::mutex> lock(mu_);
if (call_) {
- internal::CancelInterceptorBatchMethods cancel_methods;
- for (size_t i = 0; i < rpc_info_.interceptors_.size(); i++) {
- rpc_info_.RunInterceptor(&cancel_methods, i);
- }
+ SendCancelToInterceptors();
grpc_call_cancel(call_, nullptr);
} else {
call_canceled_ = true;
}
}
+void ClientContext::SendCancelToInterceptors() {
+ internal::CancelInterceptorBatchMethods cancel_methods;
+ for (size_t i = 0; i < rpc_info_.interceptors_.size(); i++) {
+ rpc_info_.RunInterceptor(&cancel_methods, i);
+ }
+}
+
grpc::string ClientContext::peer() const {
grpc::string peer;
if (call_) {