Skip to content

Commit 093e099

Browse files
authored
grpc: fix regression by freeing request bufferslice after processing unary (#7571)
1 parent 8320224 commit 093e099

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

mem/buffer_slice.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ func (s BufferSlice) Materialize() []byte {
9292
}
9393

9494
// MaterializeToBuffer functions like Materialize except that it writes the data
95-
// to a single Buffer pulled from the given BufferPool. As a special case, if the
96-
// input BufferSlice only actually has one Buffer, this function has nothing to
97-
// do and simply returns said Buffer.
95+
// to a single Buffer pulled from the given BufferPool.
96+
//
97+
// As a special case, if the input BufferSlice only actually has one Buffer, this
98+
// function simply increases the refcount before returning said Buffer. Freeing this
99+
// buffer won't release it until the BufferSlice is itself released.
98100
func (s BufferSlice) MaterializeToBuffer(pool BufferPool) Buffer {
99101
if len(s) == 1 {
100102
s[0].Ref()

server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,7 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
13591359
}
13601360
return err
13611361
}
1362+
defer d.Free()
13621363
if channelz.IsOn() {
13631364
t.IncrMsgRecv()
13641365
}

0 commit comments

Comments
 (0)