Merge pull request #19606 from arjunroy/sb_consume

Pull() eats slice from sbuf wrapped byte buffer.
pull/19637/head
Arjun Roy 5 years ago committed by GitHub
commit 0e7188ccbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/core/lib/transport/byte_stream.cc
  2. 3
      src/core/lib/transport/byte_stream.h

@ -55,17 +55,15 @@ void SliceBufferByteStream::Orphan() {
bool SliceBufferByteStream::Next(size_t max_size_hint,
grpc_closure* on_complete) {
GPR_ASSERT(cursor_ < backing_buffer_.count);
GPR_DEBUG_ASSERT(backing_buffer_.count > 0);
return true;
}
grpc_error* SliceBufferByteStream::Pull(grpc_slice* slice) {
if (shutdown_error_ != GRPC_ERROR_NONE) {
if (GPR_UNLIKELY(shutdown_error_ != GRPC_ERROR_NONE)) {
return GRPC_ERROR_REF(shutdown_error_);
}
GPR_ASSERT(cursor_ < backing_buffer_.count);
*slice = grpc_slice_ref_internal(backing_buffer_.slices[cursor_]);
++cursor_;
*slice = grpc_slice_buffer_take_first(&backing_buffer_);
return GRPC_ERROR_NONE;
}

@ -99,9 +99,8 @@ class SliceBufferByteStream : public ByteStream {
void Shutdown(grpc_error* error) override;
private:
grpc_slice_buffer backing_buffer_;
size_t cursor_ = 0;
grpc_error* shutdown_error_ = GRPC_ERROR_NONE;
grpc_slice_buffer backing_buffer_;
};
//

Loading…
Cancel
Save