aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2015-02-12 16:12:36 -0800
committerGravatar Yang Gao <yangg@google.com>2015-02-12 16:12:36 -0800
commit555a0e9e77b68a402a2d652bcd2d2003c4de998a (patch)
treefac163e7199fb736d314a9ddbfd69d63b34606a7 /src/cpp
parentcbcc977857bb81e624b5cbca3c05eb68d9797826 (diff)
parentec3257c120c5c199101ef99cff25cddccabe005e (diff)
Merge branch 'c++api' of github.com:ctiller/grpc into c++api
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/common/call.cc21
-rw-r--r--src/cpp/server/server.cc12
2 files changed, 25 insertions, 8 deletions
diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc
index aae69084eb..d706ec45e5 100644
--- a/src/cpp/common/call.cc
+++ b/src/cpp/common/call.cc
@@ -48,8 +48,7 @@ void CallOpBuffer::Reset(void* next_return_tag) {
gpr_free(initial_metadata_);
recv_initial_metadata_ = nullptr;
- gpr_free(recv_initial_metadata_arr_.metadata);
- recv_initial_metadata_arr_ = {0, 0, nullptr};
+ recv_initial_metadata_arr_.count = 0;
send_message_ = nullptr;
if (send_message_buf_) {
@@ -68,13 +67,9 @@ void CallOpBuffer::Reset(void* next_return_tag) {
recv_trailing_metadata_ = nullptr;
recv_status_ = nullptr;
- gpr_free(recv_trailing_metadata_arr_.metadata);
- recv_trailing_metadata_arr_ = {0, 0, nullptr};
+ recv_trailing_metadata_arr_.count = 0;
status_code_ = GRPC_STATUS_OK;
- gpr_free(status_details_);
- status_details_ = nullptr;
- status_details_capacity_ = 0;
send_status_ = nullptr;
trailing_metadata_count_ = 0;
@@ -83,6 +78,18 @@ void CallOpBuffer::Reset(void* next_return_tag) {
recv_closed_ = nullptr;
}
+CallOpBuffer::~CallOpBuffer() {
+ gpr_free(status_details_);
+ gpr_free(recv_initial_metadata_arr_.metadata);
+ gpr_free(recv_trailing_metadata_arr_.metadata);
+ if (recv_message_buf_) {
+ grpc_byte_buffer_destroy(recv_message_buf_);
+ }
+ if (send_message_buf_) {
+ grpc_byte_buffer_destroy(send_message_buf_);
+ }
+}
+
namespace {
// TODO(yangg) if the map is changed before we send, the pointers will be a
// mess. Make sure it does not happen.
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index 7d19834799..294eeae585 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -163,7 +163,11 @@ class Server::SyncRequest final : public CompletionQueueTag {
this));
}
- void FinalizeResult(void** tag, bool* status) override {}
+ void FinalizeResult(void** tag, bool* status) override {
+ if (!*status) {
+ grpc_completion_queue_destroy(cq_);
+ }
+ }
class CallData final {
public:
@@ -182,6 +186,12 @@ class Server::SyncRequest final : public CompletionQueueTag {
mrd->request_metadata_.count = 0;
}
+ ~CallData() {
+ if (has_request_payload_ && request_payload_) {
+ grpc_byte_buffer_destroy(request_payload_);
+ }
+ }
+
void Run() {
std::unique_ptr<google::protobuf::Message> req;
std::unique_ptr<google::protobuf::Message> res;