From ca4cf071eb6b9d6e964396832f9b529ebd50fae2 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy Date: Fri, 4 Sep 2026 14:14:47 +0300 Subject: [PATCH] pgconn: allocate the channel before locking the mutex This slightly reduces the amount of time the mutex is locked --- pgconn/pgconn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgconn/pgconn.go b/pgconn/pgconn.go index 85d4de1cb..08bfd8aeb 100644 --- a/pgconn/pgconn.go +++ b/pgconn/pgconn.go @@ -572,10 +572,10 @@ func (pgConn *PgConn) signalMessage() chan struct{} { panic("BUG: signalMessage when already in progress") } + ch := make(chan struct{}) pgConn.bufferingReceive = true pgConn.bufferingReceiveMux.Lock() - ch := make(chan struct{}) go func() { pgConn.bufferingReceiveMsg, pgConn.bufferingReceiveErr = pgConn.frontend.Receive() pgConn.bufferingReceiveMux.Unlock()