Merge pull request #20 from yang-g/c++api

AND status in FinalizeResult instead of setting it. Clear user provided recv_message proto when adding it.
pull/501/head
Craig Tiller 10 years ago
commit 41c8e27480
  1. 6
      src/cpp/common/call.cc
  2. 2
      src/cpp/server/server.cc

@ -31,6 +31,7 @@
* *
*/ */
#include <google/protobuf/message.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc++/impl/call.h> #include <grpc++/impl/call.h>
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
@ -144,6 +145,7 @@ void CallOpBuffer::AddSendMessage(const google::protobuf::Message& message) {
void CallOpBuffer::AddRecvMessage(google::protobuf::Message* message) { void CallOpBuffer::AddRecvMessage(google::protobuf::Message* message) {
recv_message_ = message; recv_message_ = message;
recv_message_->Clear();
} }
void CallOpBuffer::AddClientSendClose() { client_send_close_ = true; } void CallOpBuffer::AddClientSendClose() { client_send_close_ = true; }
@ -253,8 +255,8 @@ void CallOpBuffer::FinalizeResult(void** tag, bool* status) {
// Parse received message if any. // Parse received message if any.
if (recv_message_) { if (recv_message_) {
if (recv_message_buf_) { if (recv_message_buf_) {
got_message = true; got_message = *status;
*status = DeserializeProto(recv_message_buf_, recv_message_); *status = *status && DeserializeProto(recv_message_buf_, recv_message_);
grpc_byte_buffer_destroy(recv_message_buf_); grpc_byte_buffer_destroy(recv_message_buf_);
recv_message_buf_ = nullptr; recv_message_buf_ = nullptr;
} else { } else {

@ -314,7 +314,7 @@ class Server::AsyncRequest final : public CompletionQueueTag {
*tag = tag_; *tag = tag_;
if (*status && request_) { if (*status && request_) {
if (payload_) { if (payload_) {
*status = DeserializeProto(payload_, request_); *status = *status && DeserializeProto(payload_, request_);
} else { } else {
*status = false; *status = false;
} }

Loading…
Cancel
Save