diff options
author | Craig Tiller <ctiller@google.com> | 2017-08-31 12:23:53 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-08-31 12:23:53 -0700 |
commit | ccad38227f63797318d7cffcba8a2df783394ccd (patch) | |
tree | 64632504188bf906796763f585c11055098aab58 /include/grpc++/impl/codegen/call.h | |
parent | 6e739745e298bf205eb2553d3a3c8a3eed06fff1 (diff) | |
parent | 451b92a754900a800a7728a3d63462058026ac2c (diff) |
Merge github.com:grpc/grpc into stats
Diffstat (limited to 'include/grpc++/impl/codegen/call.h')
-rw-r--r-- | include/grpc++/impl/codegen/call.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 0cb11b4cca..8e70225f86 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -272,7 +272,7 @@ class CallOpSendInitialMetadata { class CallOpSendMessage { public: - CallOpSendMessage() : send_buf_(nullptr), own_buf_(false) {} + CallOpSendMessage() : send_buf_(nullptr) {} /// Send \a message using \a options for the write. The \a options are cleared /// after use. @@ -295,20 +295,25 @@ class CallOpSendMessage { write_options_.Clear(); } void FinishOp(bool* status) { - if (own_buf_) g_core_codegen_interface->grpc_byte_buffer_destroy(send_buf_); + g_core_codegen_interface->grpc_byte_buffer_destroy(send_buf_); send_buf_ = nullptr; } private: grpc_byte_buffer* send_buf_; WriteOptions write_options_; - bool own_buf_; }; template <class M> Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) { write_options_ = options; - return SerializationTraits<M>::Serialize(message, &send_buf_, &own_buf_); + bool own_buf; + Status result = + SerializationTraits<M>::Serialize(message, &send_buf_, &own_buf); + if (!own_buf) { + send_buf_ = g_core_codegen_interface->grpc_byte_buffer_copy(send_buf_); + } + return result; } template <class M> |