Skip to content

Commit

Permalink
Merge pull request ipfs#19 from ipfs/bugs/fix-leftover-go-routines
Browse files Browse the repository at this point in the history
Wait for all go routines to finish before function returns
  • Loading branch information
Stebalien authored Nov 8, 2018
2 parents 7e8e37d + d845d6a commit b1b06bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,16 @@ func EnumerateChildrenAsyncDepth(ctx context.Context, getLinks GetLinks, c cid.C
done := make(chan struct{})

var setlk sync.Mutex
var wg sync.WaitGroup

errChan := make(chan error)
fetchersCtx, cancel := context.WithCancel(ctx)

defer wg.Wait()
defer cancel()

for i := 0; i < FetchGraphConcurrency; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for cdepth := range feed {
ci := cdepth.cid
depth := cdepth.depth
Expand Down

0 comments on commit b1b06bd

Please sign in to comment.