Skip to content

Commit

Permalink
Return buffers to pool on network errors or queue overflow (#2609)
Browse files Browse the repository at this point in the history
Use of sync.Pool requires a .Put for every .Get.
On success, the downstream ThriftProcessor invoked .Put via .DataRecd
but in error cases there seems to be a leak.

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
  • Loading branch information
chlunde committed Oct 30, 2020
1 parent ec03a2d commit be49a63
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/agent/app/servers/tbuffered_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ func (s *TBufferedServer) Serve() {
s.metrics.PacketsProcessed.Inc(1)
s.updateQueueSize(1)
default:
s.readBufPool.Put(readBuf)
s.metrics.PacketsDropped.Inc(1)
}
} else {
s.readBufPool.Put(readBuf)
s.metrics.ReadError.Inc(1)
}
}
Expand Down

0 comments on commit be49a63

Please sign in to comment.