From be49a63f36f2468f9533a79454139d346dc99acc Mon Sep 17 00:00:00 2001 From: Carl Henrik Lunde Date: Fri, 30 Oct 2020 22:38:47 +0100 Subject: [PATCH] Return buffers to pool on network errors or queue overflow (#2609) 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 --- cmd/agent/app/servers/tbuffered_server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/agent/app/servers/tbuffered_server.go b/cmd/agent/app/servers/tbuffered_server.go index fbb3f53d209..5ba757ffb65 100644 --- a/cmd/agent/app/servers/tbuffered_server.go +++ b/cmd/agent/app/servers/tbuffered_server.go @@ -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) } }