From 4d5f8a5df319a6561b3d48eec4c00d86b06e65df Mon Sep 17 00:00:00 2001 From: wanglei6 Date: Thu, 30 Apr 2020 14:34:48 +0800 Subject: [PATCH] fix data race --- internal/pool/pool.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/pool/pool.go b/internal/pool/pool.go index bbf5b30..36f6953 100644 --- a/internal/pool/pool.go +++ b/internal/pool/pool.go @@ -93,8 +93,9 @@ func NewConnPool(opt *Options) *ConnPool { idleConns: make([]*Conn, 0, opt.PoolSize), closedCh: make(chan struct{}), } - + p.connsMu.Lock() p.checkMinIdleConns() + p.connsMu.Unlock() if opt.IdleTimeout > 0 && opt.IdleCheckFrequency > 0 { go p.reaper(opt.IdleCheckFrequency)