From 8dafd52cea3daace6c0f9ae40a07f8782a86379e Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 24 Mar 2015 11:36:17 -0700 Subject: [PATCH] Revert "Remove dead members of server context" This reverts commit 8c8588c7dc047ee509c7367f61ba0c5f00cb61d1. --- include/grpc++/server_context.h | 3 +++ src/cpp/server/server_context.cc | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h index 36cbae87a00..9e3b80c6411 100644 --- a/include/grpc++/server_context.h +++ b/include/grpc++/server_context.h @@ -78,6 +78,8 @@ class ServerContext { void AddInitialMetadata(const grpc::string& key, const grpc::string& value); void AddTrailingMetadata(const grpc::string& key, const grpc::string& value); + bool IsCancelled(); + const std::multimap& client_metadata() { return client_metadata_; } @@ -110,6 +112,7 @@ class ServerContext { std::chrono::system_clock::time_point deadline_; grpc_call* call_; + CompletionQueue* cq_; bool sent_initial_metadata_; std::multimap client_metadata_; std::multimap initial_metadata_; diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 435a060be5a..bb3c2d1405f 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -94,6 +94,7 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) { ServerContext::ServerContext() : completion_op_(nullptr), call_(nullptr), + cq_(nullptr), sent_initial_metadata_(false) {} ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata, @@ -101,6 +102,7 @@ ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata, : completion_op_(nullptr), deadline_(Timespec2Timepoint(deadline)), call_(nullptr), + cq_(nullptr), sent_initial_metadata_(false) { for (size_t i = 0; i < metadata_count; i++) { client_metadata_.insert(std::make_pair( @@ -135,4 +137,8 @@ void ServerContext::AddTrailingMetadata(const grpc::string& key, trailing_metadata_.insert(std::make_pair(key, value)); } +bool ServerContext::IsCancelled() { + return completion_op_ && completion_op_->CheckCancelled(cq_); +} + } // namespace grpc