From 2cd0ce3f9b2d8daff93ed1d5211510346a2e2854 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Thu, 2 Apr 2020 22:10:13 -0500 Subject: [PATCH] Closing a closed pool is a no-op --- pool.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pool.go b/pool.go index fb79e1c..aa0022f 100644 --- a/pool.go +++ b/pool.go @@ -144,6 +144,10 @@ func NewPool(constructor Constructor, destructor Destructor, maxSize int32) *Poo // Blocks until all resources are returned to pool and destroyed. func (p *Pool) Close() { p.cond.L.Lock() + if p.closed { + p.cond.L.Unlock() + return + } p.closed = true for _, res := range p.idleResources {