Skip to content

Commit 4373801

Browse files
authored
fix: fix the maxActiveConns sematic
1 parent d43a9fa commit 4373801

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/pool/pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) {
169169
}
170170

171171
p.connsMu.Lock()
172-
if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns {
172+
if p.cfg.MaxActiveConns > 0 && len(p.conns) >= p.cfg.MaxActiveConns {
173173
p.connsMu.Unlock()
174174
return nil, ErrPoolExhausted
175175
}
@@ -183,7 +183,7 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) {
183183
p.connsMu.Lock()
184184
defer p.connsMu.Unlock()
185185

186-
if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns {
186+
if p.cfg.MaxActiveConns > 0 && len(p.conns) >= p.cfg.MaxActiveConns {
187187
_ = cn.Close()
188188
return nil, ErrPoolExhausted
189189
}

0 commit comments

Comments
 (0)