diff options
author | Vijay Pai <vpai@google.com> | 2015-04-02 11:56:32 -0700 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2015-04-02 11:56:32 -0700 |
commit | 63adffe3f4611d668e980964ba7133126ec89158 (patch) | |
tree | 274d3b7d0840c561b228b352f256909fc5239832 /src | |
parent | bd946ebcd7540491a514316f798f8b55621344b3 (diff) | |
parent | e9866e977e625e5876ca3f1d61b606dfca74dc60 (diff) |
Merge pull request #1177 from yang-g/bugfix
Bug fix. User can destroy status after calling Finish and we should keep...
Diffstat (limited to 'src')
-rw-r--r-- | src/cpp/common/call.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc index 1599e5117f..e75e77e0b5 100644 --- a/src/cpp/common/call.cc +++ b/src/cpp/common/call.cc @@ -60,7 +60,8 @@ CallOpBuffer::CallOpBuffer() status_code_(GRPC_STATUS_OK), status_details_(nullptr), status_details_capacity_(0), - send_status_(nullptr), + send_status_available_(false), + send_status_code_(GRPC_STATUS_OK), trailing_metadata_count_(0), trailing_metadata_(nullptr), cancelled_buf_(0), @@ -104,7 +105,9 @@ void CallOpBuffer::Reset(void* next_return_tag) { status_code_ = GRPC_STATUS_OK; - send_status_ = nullptr; + send_status_available_ = false; + send_status_code_ = GRPC_STATUS_OK; + send_status_details_.clear(); trailing_metadata_count_ = 0; trailing_metadata_ = nullptr; @@ -208,7 +211,9 @@ void CallOpBuffer::AddServerSendStatus( } else { trailing_metadata_count_ = 0; } - send_status_ = &status; + send_status_available_ = true; + send_status_code_ = static_cast<grpc_status_code>(status.code()); + send_status_details_ = status.details(); } void CallOpBuffer::FillOps(grpc_op* ops, size_t* nops) { @@ -257,16 +262,15 @@ void CallOpBuffer::FillOps(grpc_op* ops, size_t* nops) { &status_details_capacity_; (*nops)++; } - if (send_status_) { + if (send_status_available_) { ops[*nops].op = GRPC_OP_SEND_STATUS_FROM_SERVER; ops[*nops].data.send_status_from_server.trailing_metadata_count = trailing_metadata_count_; ops[*nops].data.send_status_from_server.trailing_metadata = trailing_metadata_; - ops[*nops].data.send_status_from_server.status = - static_cast<grpc_status_code>(send_status_->code()); + ops[*nops].data.send_status_from_server.status = send_status_code_; ops[*nops].data.send_status_from_server.status_details = - send_status_->details().c_str(); + send_status_details_.empty() ? nullptr : send_status_details_.c_str(); (*nops)++; } if (recv_closed_) { |