Skip to content

Commit

Permalink
fix: Fix deadlock raised in neilotoole#11
Browse files Browse the repository at this point in the history
  • Loading branch information
said-saifi committed Mar 31, 2022
1 parent 2767a51 commit 0998b0e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions errgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,20 @@ func (g *Group) Go(f func() error) {
return
}

g.qCh <- f

// Check if we can or should start a new goroutine?
g.maybeStartG()
for {
if g.err != nil {
g.qMu.Unlock()
return
}

g.qMu.Unlock()
select {
case g.qCh <- f:
g.maybeStartG()
g.qMu.Unlock()
return
}

}
}

// maybeStartG might start a new worker goroutine, if
Expand Down

0 comments on commit 0998b0e

Please sign in to comment.