Skip to content

Commit 0f388ad

Browse files
committed
Fix race in checkMinIdleConns
1 parent 0d905a8 commit 0f388ad

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/*
2-
Package pg implements a PostgreSQL client.
2+
pg provides PostgreSQL client.
33
*/
44
package pg

internal/internal.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*
2+
internal is a private internal package.
3+
*/
14
package internal
25

36
import (

internal/pool/pool.go

+2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ func NewConnPool(opt *Options) *ConnPool {
9393
idleConns: make([]*Conn, 0, opt.PoolSize),
9494
}
9595

96+
p.connsMu.Lock()
9697
p.checkMinIdleConns()
98+
p.connsMu.Unlock()
9799

98100
if opt.IdleTimeout > 0 && opt.IdleCheckFrequency > 0 {
99101
go p.reaper(opt.IdleCheckFrequency)

0 commit comments

Comments
 (0)