diff options
Diffstat (limited to 'src/cpp/server/server_cc.cc')
-rw-r--r-- | src/cpp/server/server_cc.cc | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 817d85a81c..dcc56eecbc 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -576,7 +576,6 @@ ServerInterface::BaseAsyncRequest::BaseAsyncRequest( delete_on_finalize_(delete_on_finalize), call_(nullptr) { call_cq_->RegisterAvalanching(); // This op will trigger more ops - memset(&initial_metadata_array_, 0, sizeof(initial_metadata_array_)); } ServerInterface::BaseAsyncRequest::~BaseAsyncRequest() { @@ -586,16 +585,8 @@ ServerInterface::BaseAsyncRequest::~BaseAsyncRequest() { bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag, bool* status) { if (*status) { - for (size_t i = 0; i < initial_metadata_array_.count; i++) { - context_->client_metadata_.insert( - std::pair<grpc::string_ref, grpc::string_ref>( - initial_metadata_array_.metadata[i].key, - grpc::string_ref( - initial_metadata_array_.metadata[i].value, - initial_metadata_array_.metadata[i].value_length))); - } + context_->client_metadata_.FillMap(); } - grpc_metadata_array_destroy(&initial_metadata_array_); context_->set_call(call_); context_->cq_ = call_cq_; Call call(call_, server_, call_cq_, server_->max_receive_message_size()); @@ -621,8 +612,8 @@ void ServerInterface::RegisteredAsyncRequest::IssueRequest( ServerCompletionQueue* notification_cq) { grpc_server_request_registered_call( server_->server(), registered_method, &call_, &context_->deadline_, - &initial_metadata_array_, payload, call_cq_->cq(), notification_cq->cq(), - this); + context_->client_metadata_.arr(), payload, call_cq_->cq(), + notification_cq->cq(), this); } ServerInterface::GenericAsyncRequest::GenericAsyncRequest( @@ -635,7 +626,7 @@ ServerInterface::GenericAsyncRequest::GenericAsyncRequest( GPR_ASSERT(notification_cq); GPR_ASSERT(call_cq); grpc_server_request_call(server->server(), &call_, &call_details_, - &initial_metadata_array_, call_cq->cq(), + context->client_metadata_.arr(), call_cq->cq(), notification_cq->cq(), this); } @@ -644,11 +635,12 @@ bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag, // TODO(yangg) remove the copy here. if (*status) { static_cast<GenericServerContext*>(context_)->method_ = - call_details_.method; - static_cast<GenericServerContext*>(context_)->host_ = call_details_.host; + StringFromCopiedSlice(call_details_.method); + static_cast<GenericServerContext*>(context_)->host_ = + StringFromCopiedSlice(call_details_.host); } - gpr_free(call_details_.method); - gpr_free(call_details_.host); + grpc_slice_unref(call_details_.method); + grpc_slice_unref(call_details_.host); return BaseAsyncRequest::FinalizeResult(tag, status); } |