Merge branch 'one-shouldnt-depend-on-protobufs' of github.com:ctiller/grpc into one-shouldnt-depend-on-protobufs

pull/1969/head
Craig Tiller 10 years ago
commit e22fb4e3e5
  1. 17
      include/grpc++/impl/call.h
  2. 5
      include/grpc++/impl/proto_utils.h
  3. 2
      include/grpc++/server.h
  4. 2
      src/cpp/server/server.cc

@ -34,7 +34,7 @@
#ifndef GRPCXX_IMPL_CALL_H
#define GRPCXX_IMPL_CALL_H
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc++/client_context.h>
#include <grpc++/completion_queue.h>
#include <grpc++/config.h>
@ -85,6 +85,8 @@ class CallOpSendInitialMetadata {
op->data.send_initial_metadata.metadata = initial_metadata_;
}
void FinishOp(bool* status, int max_message_size) {
if (!send_) return;
gpr_free(initial_metadata_);
send_ = false;
}
@ -244,6 +246,7 @@ class CallOpServerSendStatus {
protected:
void AddOp(grpc_op* ops, size_t* nops) {
if (!send_status_available_) return;
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count =
@ -255,7 +258,9 @@ class CallOpServerSendStatus {
}
void FinishOp(bool* status, int max_message_size) {
send_status_details_ = false;
if (!send_status_available_) return;
gpr_free(trailing_metadata_);
send_status_available_ = false;
}
private:
@ -269,7 +274,6 @@ class CallOpServerSendStatus {
class CallOpRecvInitialMetadata {
public:
CallOpRecvInitialMetadata() : recv_initial_metadata_(nullptr) {
memset(&recv_initial_metadata_arr_, 0, sizeof(recv_initial_metadata_arr_));
}
void RecvInitialMetadata(ClientContext* context) {
@ -280,6 +284,7 @@ class CallOpRecvInitialMetadata {
protected:
void AddOp(grpc_op* ops, size_t* nops) {
if (!recv_initial_metadata_) return;
memset(&recv_initial_metadata_arr_, 0, sizeof(recv_initial_metadata_arr_));
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata = &recv_initial_metadata_arr_;
@ -297,7 +302,7 @@ class CallOpRecvInitialMetadata {
class CallOpClientRecvStatus {
public:
CallOpClientRecvStatus() { memset(this, 0, sizeof(*this)); }
CallOpClientRecvStatus() : recv_status_(nullptr) {}
void ClientRecvStatus(ClientContext* context, Status* status) {
recv_trailing_metadata_ = &context->trailing_metadata_;
@ -307,6 +312,9 @@ class CallOpClientRecvStatus {
protected:
void AddOp(grpc_op* ops, size_t* nops) {
if (recv_status_ == nullptr) return;
memset(&recv_trailing_metadata_arr_, 0, sizeof(recv_trailing_metadata_arr_));
status_details_ = nullptr;
status_details_capacity_ = 0;
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata =
@ -323,6 +331,7 @@ class CallOpClientRecvStatus {
*recv_status_ = Status(
static_cast<StatusCode>(status_code_),
status_details_ ? grpc::string(status_details_) : grpc::string());
gpr_free(status_details_);
recv_status_ = nullptr;
}

@ -36,6 +36,7 @@
#include <type_traits>
#include <grpc/grpc.h>
#include <grpc++/impl/serialization_traits.h>
#include <grpc++/config_protobuf.h>
#include <grpc++/status.h>
@ -66,7 +67,9 @@ class SerializationTraits<T, typename std::enable_if<std::is_base_of<
static Status Deserialize(grpc_byte_buffer* buffer,
grpc::protobuf::Message* msg,
int max_message_size) {
return DeserializeProto(buffer, msg, max_message_size);
auto status = DeserializeProto(buffer, msg, max_message_size);
grpc_byte_buffer_destroy(buffer);
return status;
}
};

@ -108,8 +108,6 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE;
protected:
void FinalizeMetadata(ServerContext* context);
Server* const server_;
ServerContext* const context_;
ServerAsyncStreamingInterface* const stream_;

@ -129,6 +129,7 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
ctx_.BeginCompletionOp(&call_);
method_->handler()->RunHandler(MethodHandler::HandlerParameter(
&call_, &ctx_, request_payload_, call_.max_message_size()));
request_payload_ = nullptr;
void* ignored_tag;
bool ignored_ok;
cq_.Shutdown();
@ -316,6 +317,7 @@ bool Server::BaseAsyncRequest::FinalizeResult(void** tag, bool* status) {
initial_metadata_array_.metadata[i].value_length)));
}
}
grpc_metadata_array_destroy(&initial_metadata_array_);
context_->call_ = call_;
context_->cq_ = call_cq_;
Call call(call_, server_, call_cq_, server_->max_message_size_);

Loading…
Cancel
Save