Skip to content

Commit

Permalink
grpc: fix regression by freeing request bufferslice after processing …
Browse files Browse the repository at this point in the history
…unary (#7571)
  • Loading branch information
coxley authored Aug 30, 2024
1 parent 8320224 commit 093e099
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mem/buffer_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ func (s BufferSlice) Materialize() []byte {
}

// MaterializeToBuffer functions like Materialize except that it writes the data
// to a single Buffer pulled from the given BufferPool. As a special case, if the
// input BufferSlice only actually has one Buffer, this function has nothing to
// do and simply returns said Buffer.
// to a single Buffer pulled from the given BufferPool.
//
// As a special case, if the input BufferSlice only actually has one Buffer, this
// function simply increases the refcount before returning said Buffer. Freeing this
// buffer won't release it until the BufferSlice is itself released.
func (s BufferSlice) MaterializeToBuffer(pool BufferPool) Buffer {
if len(s) == 1 {
s[0].Ref()
Expand Down
1 change: 1 addition & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,7 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
}
return err
}
defer d.Free()
if channelz.IsOn() {
t.IncrMsgRecv()
}
Expand Down

0 comments on commit 093e099

Please sign in to comment.