Merge pull request #1 from lawlielt/lawlielt-patch-1

fix: fix the maxActiveConns sematic
This commit is contained in:
lawlielt 2024-03-05 17:16:33 +08:00 committed by GitHub
commit 960b7a3361
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -169,7 +169,7 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) {
}
p.connsMu.Lock()
if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns {
if p.cfg.MaxActiveConns > 0 && len(p.conns) >= p.cfg.MaxActiveConns {
p.connsMu.Unlock()
return nil, ErrPoolExhausted
}
@ -183,7 +183,7 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) {
p.connsMu.Lock()
defer p.connsMu.Unlock()
if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns {
if p.cfg.MaxActiveConns > 0 && len(p.conns) >= p.cfg.MaxActiveConns {
_ = cn.Close()
return nil, ErrPoolExhausted
}