Skip to content

Commit

Permalink
rpc_util: Copy the buffer only if the pool option is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hueypark committed Feb 25, 2023
1 parent cbaef54 commit f9730dd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rpc_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,15 @@ func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m interf
if err := c.Unmarshal(buf, m); err != nil {
return status.Errorf(codes.Internal, "grpc: failed to unmarshal the received message: %v", err)
}
if payInfo != nil && len(buf) != 0 {
payInfo.uncompressedBytes = make([]byte, len(buf))
copy(payInfo.uncompressedBytes, buf)
if payInfo != nil {
if p.useBytesPool {
if len(buf) != 0 {
payInfo.uncompressedBytes = make([]byte, len(buf))
copy(payInfo.uncompressedBytes, buf)
}
} else {
payInfo.uncompressedBytes = buf
}
}
if p.useBytesPool {
pool.Put(&buf)
Expand Down

0 comments on commit f9730dd

Please sign in to comment.