From 7cc1dd1985b2a30f0805db9b7a539bdf3b2ef212 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Thu, 2 Apr 2020 22:11:22 -0500 Subject: [PATCH] CreateResource checks if pool is closed before any action --- pool.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pool.go b/pool.go index 262e110..b5003cc 100644 --- a/pool.go +++ b/pool.go @@ -381,6 +381,12 @@ func (p *Pool) AcquireAllIdle() []*Resource { // It goes straight in the IdlePool. It does not check against maxSize. // It can be useful to maintain warm resources under little load. func (p *Pool) CreateResource(ctx context.Context) error { + p.cond.L.Lock() + if p.closed { + p.cond.L.Unlock() + return ErrClosedPool + } + p.cond.L.Unlock() value, err := p.constructResourceValue(ctx) if err != nil {