From 7941518809470cd3dbb40b82fdd916bdc165b16b Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Fri, 27 Jan 2023 18:03:38 -0600 Subject: [PATCH] BufferReadUntilBlock should release buf when no bytes read This was causing allocations every time there was a non-blocking read with nothing to read. https://github.com/jackc/pgx/issues/1481 --- internal/nbconn/nbconn.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/nbconn/nbconn.go b/internal/nbconn/nbconn.go index cae69849..eb751509 100644 --- a/internal/nbconn/nbconn.go +++ b/internal/nbconn/nbconn.go @@ -317,6 +317,8 @@ func (c *NetConn) BufferReadUntilBlock() error { if n > 0 { buf = buf[:n] c.readQueue.pushBack(buf) + } else if n == 0 { + iobufpool.Put(buf) } if err != nil {