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
pull/1490/head
Jack Christensen 2023-01-27 18:03:38 -06:00
parent f839d501a7
commit 7941518809
1 changed files with 2 additions and 0 deletions

View File

@ -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 {