diff options
author | Yang Gao <yangg@google.com> | 2015-04-02 09:24:39 -0700 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2015-04-02 09:24:39 -0700 |
commit | b53af532afaf9458ea279d3a97e249bd59732f0f (patch) | |
tree | 56695cc128a48f62bc7194f9462d1da7080d3090 /src | |
parent | 1bd4736527ca691217b56e8287e4121a9d4fc684 (diff) |
Bug fix. User can destroy status after calling Finish and we should keep a copy of it instead of a pointer
Diffstat (limited to 'src')
-rw-r--r-- | src/cpp/common/call.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc index 1599e5117f..b013f28ac3 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_(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_ = 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_ = 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) { @@ -263,10 +268,9 @@ void CallOpBuffer::FillOps(grpc_op* ops, size_t* nops) { 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_) { |