2
0

Fix crash when pool is closed when resource is being created

Also, restore 100% test coverage.
This commit is contained in:
Jack Christensen
2020-08-20 21:57:05 -05:00
parent 6d0ef02e90
commit 91d0159cc9
3 changed files with 48 additions and 1 deletions
+1 -1
View File
@@ -400,6 +400,7 @@ func (p *Pool) CreateResource(ctx context.Context) error {
value: value,
lastUsedNano: nanotime(),
}
p.destructWG.Add(1)
p.cond.L.Lock()
// If closed while constructing resource then destroy it and return an error
@@ -409,7 +410,6 @@ func (p *Pool) CreateResource(ctx context.Context) error {
}
p.allResources = append(p.allResources, res)
p.idleResources = append(p.idleResources, res)
p.destructWG.Add(1)
p.cond.L.Unlock()
return nil