2
0

Do not leave pool lock after panic from nil context

refs #13
This commit is contained in:
Jack Christensen
2021-11-13 17:39:29 -06:00
parent 69a4c02937
commit 4d33264d63
2 changed files with 17 additions and 1 deletions
+3 -1
View File
@@ -276,10 +276,10 @@ func (p *Pool) TryAcquire(ctx context.Context) (*Resource, error) {
// will return ErrNotAvailable if no resource is available.
func (p *Pool) doAcquire(ctx context.Context, block bool) (*Resource, error) {
startNano := nanotime()
p.cond.L.Lock()
if doneChan := ctx.Done(); doneChan != nil {
select {
case <-ctx.Done():
p.cond.L.Lock()
p.canceledAcquireCount += 1
p.cond.L.Unlock()
return nil, ctx.Err()
@@ -287,6 +287,8 @@ func (p *Pool) doAcquire(ctx context.Context, block bool) (*Resource, error) {
}
}
p.cond.L.Lock()
emptyAcquire := false
for {