2
0

CreateResource checks if pool is closed before any action

This commit is contained in:
Jack Christensen
2020-04-02 22:11:22 -05:00
parent 69489dce36
commit 7cc1dd1985
+6
View File
@@ -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 {