Directly use the ZeroCopyInputStream for grpc::GenericDeserialize.

There is no need to use CodedInputStream, wrapping a
ZeroCopyInputStream.

Suggested by: Gerben Stavenga
pull/19920/head
Soheil Hassas Yeganeh 6 years ago
parent 5bf40ae30e
commit eadd5ea110
  1. 7
      include/grpcpp/impl/codegen/proto_utils.h

@ -83,14 +83,9 @@ Status GenericDeserialize(ByteBuffer* buffer,
if (!reader.status().ok()) { if (!reader.status().ok()) {
return reader.status(); return reader.status();
} }
::grpc::protobuf::io::CodedInputStream decoder(&reader); if (!msg->ParseFromZeroCopyStream(&reader)) {
decoder.SetTotalBytesLimit(INT_MAX, INT_MAX);
if (!msg->ParseFromCodedStream(&decoder)) {
result = Status(StatusCode::INTERNAL, msg->InitializationErrorString()); result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
} }
if (!decoder.ConsumedEntireMessage()) {
result = Status(StatusCode::INTERNAL, "Did not read entire message");
}
} }
buffer->Clear(); buffer->Clear();
return result; return result;

Loading…
Cancel
Save