Skip to content

Commit b3d1954

Browse files
committed
fix ConnPool race in newConn
1 parent 2512123 commit b3d1954

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/pool/pool.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,12 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) {
168168
return nil, ErrClosed
169169
}
170170

171+
p.connsMu.Lock()
171172
if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns {
173+
p.connsMu.Unlock()
172174
return nil, ErrPoolExhausted
173175
}
176+
p.connsMu.Unlock()
174177

175178
cn, err := p.dialConn(ctx, pooled)
176179
if err != nil {

0 commit comments

Comments
 (0)