From 87f604284830ba7b2f3bd9854ef152caa4b5621b Mon Sep 17 00:00:00 2001 From: Stephen Fox Date: Sat, 21 Mar 2020 19:15:36 -0400 Subject: [PATCH] Always decrement the WaitGroup, even if the 'doer' ends. --- cmd/finley/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/finley/main.go b/cmd/finley/main.go index 1245b20..a15193b 100644 --- a/cmd/finley/main.go +++ b/cmd/finley/main.go @@ -247,6 +247,7 @@ type doer struct { func (o *doer) queue(fn func() error) { o.wg.Add(1) go func() { + defer o.wg.Done() select { case workerID := <-o.pool: err := fn() @@ -256,10 +257,8 @@ func (o *doer) queue(fn func() error) { default: close(o.dead) } - o.wg.Done() return } - o.wg.Done() o.pool <- workerID case <-o.dead: return