Merge pull request #21454 from grpc/revert-21385-generic_unary

Revert "Generic API: assert when sending uninitialized byte buffer"
pull/21443/head
Esun Kim 5 years ago committed by GitHub
commit f257562786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      include/grpcpp/impl/codegen/byte_buffer.h
  2. 11
      include/grpcpp/impl/codegen/call_op_set.h

@ -63,16 +63,13 @@ class DeserializeFuncType;
class GrpcByteBufferPeer;
} // namespace internal
/// A sequence of bytes. A ByteBuffer must be backed by at least one slice to be
/// considered valid. You can consstruct an empty buffer through creating a
/// ByteBuffer backed by one empty slice.
/// A sequence of bytes.
class ByteBuffer final {
public:
/// Construct an uninitialized buffer.
/// Constuct an empty buffer.
ByteBuffer() : buffer_(nullptr) {}
/// Construct buffer from \a slices, of which there are \a nslices. \a slices
/// must be a valid pointer.
/// Construct buffer from \a slices, of which there are \a nslices.
ByteBuffer(const Slice* slices, size_t nslices) {
// The following assertions check that the representation of a grpc::Slice
// is identical to that of a grpc_slice: it has a grpc_slice field, and

@ -310,12 +310,7 @@ class CallOpSendMessage {
protected:
void AddOp(grpc_op* ops, size_t* nops) {
if (msg_ == nullptr && !send_buf_.Valid()) {
// If SendMessage was called, this is an API misuse, since we're
// attempting to send an invalid message.
GPR_CODEGEN_DEBUG_ASSERT(!send_message_called_);
return;
}
if (msg_ == nullptr && !send_buf_.Valid()) return;
if (hijacked_) {
serializer_ = nullptr;
return;
@ -334,7 +329,6 @@ class CallOpSendMessage {
}
void FinishOp(bool* status) {
if (msg_ == nullptr && !send_buf_.Valid()) return;
send_message_called_ = false;
if (hijacked_ && failed_send_) {
// Hijacking interceptor failed this Op
*status = false;
@ -375,7 +369,6 @@ class CallOpSendMessage {
const void* msg_ = nullptr; // The original non-serialized message
bool hijacked_ = false;
bool failed_send_ = false;
bool send_message_called_ = false;
ByteBuffer send_buf_;
WriteOptions write_options_;
std::function<Status(const void*)> serializer_;
@ -383,8 +376,6 @@ class CallOpSendMessage {
template <class M>
Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) {
GPR_CODEGEN_DEBUG_ASSERT(!send_message_called_);
send_message_called_ = true;
write_options_ = options;
serializer_ = [this](const void* message) {
bool own_buf;

Loading…
Cancel
Save