Let ServerContext own the initial_metadata array for sync calls

pull/9718/head
yang-g 8 years ago
parent 25bbef639e
commit c42d844d27
  1. 3
      include/grpc++/impl/codegen/server_context.h
  2. 3
      src/cpp/server/server_cc.cc
  3. 13
      src/cpp/server/server_context.cc

@ -213,8 +213,7 @@ class ServerContext {
void BeginCompletionOp(Call* call);
ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
size_t metadata_count);
ServerContext(gpr_timespec deadline, grpc_metadata_array* arr);
void set_call(grpc_call* call) { call_ = call; }

@ -189,8 +189,7 @@ class Server::SyncRequest final : public CompletionQueueTag {
explicit CallData(Server* server, SyncRequest* mrd)
: cq_(mrd->cq_),
call_(mrd->call_, server, &cq_, server->max_receive_message_size()),
ctx_(mrd->deadline_, mrd->request_metadata_.metadata,
mrd->request_metadata_.count),
ctx_(mrd->deadline_, &mrd->request_metadata_),
has_request_payload_(mrd->has_request_payload_),
request_payload_(mrd->request_payload_),
method_(mrd->method_) {

@ -33,7 +33,9 @@
#include <grpc++/server_context.h>
#include <algorithm>
#include <mutex>
#include <utility>
#include <grpc++/completion_queue.h>
#include <grpc++/impl/call.h>
@ -133,8 +135,7 @@ ServerContext::ServerContext()
sent_initial_metadata_(false),
compression_level_set_(false) {}
ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
size_t metadata_count)
ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata_array* arr)
: completion_op_(nullptr),
has_notify_when_done_tag_(false),
async_notify_when_done_tag_(nullptr),
@ -143,12 +144,8 @@ ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
cq_(nullptr),
sent_initial_metadata_(false),
compression_level_set_(false) {
for (size_t i = 0; i < metadata_count; i++) {
client_metadata_.map()->insert(
std::pair<grpc::string_ref, grpc::string_ref>(
StringRefFromSlice(&metadata[i].key),
StringRefFromSlice(&metadata[i].value)));
}
std::swap(*client_metadata_.arr(), *arr);
client_metadata_.FillMap();
}
ServerContext::~ServerContext() {

Loading…
Cancel
Save