diff options
author | Craig Tiller <ctiller@google.com> | 2017-08-31 12:24:15 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-08-31 12:24:15 -0700 |
commit | 890f542498a8af4c05f22e42d818f3b0eeafaea8 (patch) | |
tree | 4ccf813375c1744629ed43c5c5eaa62fbdffe7ac /include/grpc++/impl/codegen/call.h | |
parent | 5489d41c15926abbf12a5b8d27b24d1d605d7f0f (diff) | |
parent | ccad38227f63797318d7cffcba8a2df783394ccd (diff) |
Merge branch 'stats' into stats_histo
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> |