Skip to content

Commit

Permalink
Always decrement the WaitGroup, even if the 'doer' ends.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-fox committed Mar 21, 2020
1 parent 4b10627 commit 87f6042
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/finley/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 87f6042

Please sign in to comment.