Skip to content

Commit 960b7a3

Browse files
authored
Merge pull request #1 from lawlielt/lawlielt-patch-1
fix: fix the maxActiveConns sematic
2 parents d43a9fa + 4373801 commit 960b7a3

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)