Commit d845d6a2 authored by hannahhoward's avatar hannahhoward

Wait for all go routines to finish before function returns

parent 7e8e37de
...@@ -376,14 +376,16 @@ func EnumerateChildrenAsyncDepth(ctx context.Context, getLinks GetLinks, c cid.C ...@@ -376,14 +376,16 @@ func EnumerateChildrenAsyncDepth(ctx context.Context, getLinks GetLinks, c cid.C
done := make(chan struct{}) done := make(chan struct{})
var setlk sync.Mutex var setlk sync.Mutex
var wg sync.WaitGroup
errChan := make(chan error) errChan := make(chan error)
fetchersCtx, cancel := context.WithCancel(ctx) fetchersCtx, cancel := context.WithCancel(ctx)
defer wg.Wait()
defer cancel() defer cancel()
for i := 0; i < FetchGraphConcurrency; i++ { for i := 0; i < FetchGraphConcurrency; i++ {
wg.Add(1)
go func() { go func() {
defer wg.Done()
for cdepth := range feed { for cdepth := range feed {
ci := cdepth.cid ci := cdepth.cid
depth := cdepth.depth depth := cdepth.depth
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment