aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/server/server_context.cc
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-02-03 16:23:45 -0800
committerGravatar Vijay Pai <vpai@google.com>2016-02-03 16:23:45 -0800
commit912fe05ed38f55a69c47d6753cdf5073f9250345 (patch)
treebfeb9331f86a54a324876e37dd3dce9a2b7ab339 /src/cpp/server/server_context.cc
parentfeef8be5aeba73fa2d96ec282d1da8b885340f62 (diff)
parent87afe8c12f99cc73ed344be966b3eb7b00443a6f (diff)
Merge branch 'master' into async_thread_stress_test
Diffstat (limited to 'src/cpp/server/server_context.cc')
-rw-r--r--src/cpp/server/server_context.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index 3732c1f090..e205a1969b 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -33,14 +33,14 @@
#include <grpc++/server_context.h>
-#include <grpc/compression.h>
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
#include <grpc++/completion_queue.h>
#include <grpc++/impl/call.h>
#include <grpc++/impl/sync.h>
#include <grpc++/support/time.h>
+#include <grpc/compression.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
#include "src/core/channel/compress_filter.h"
#include "src/cpp/common/create_auth_context.h"
@@ -173,6 +173,14 @@ void ServerContext::AddTrailingMetadata(const grpc::string& key,
trailing_metadata_.insert(std::make_pair(key, value));
}
+void ServerContext::TryCancel() const {
+ grpc_call_error err = grpc_call_cancel_with_status(
+ call_, GRPC_STATUS_CANCELLED, "Cancelled on the server side", NULL);
+ if (err != GRPC_CALL_OK) {
+ gpr_log(GPR_ERROR, "TryCancel failed with: %d", err);
+ }
+}
+
bool ServerContext::IsCancelled() const {
return completion_op_ && completion_op_->CheckCancelled(cq_);
}