Skip to content

Commit

Permalink
fix(repo.WalkRepoDatasets): remove data race
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Nov 17, 2017
1 parent c3be454 commit 56862e2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions repo/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,19 @@ func WalkRepoDatasets(r Repo, visit func(depth int, ref *DatasetRef, err error)
}

pageSize := count / pll
pll++
done := make(chan error, pll)
for i := 0; i < pll; i++ {
go doSection(i, pageSize, done)
}

for i := 0; i < pll; i++ {
err := <-done
if err != nil {
return err
}
}

// TODO - make properly parallel
go func() {
refs, err := r.GetQueryLogs(1000, 0)
if err != nil {
Expand Down Expand Up @@ -254,16 +265,5 @@ func WalkRepoDatasets(r Repo, visit func(depth int, ref *DatasetRef, err error)
done <- nil
}()

for i := 0; i < pll; i++ {
go doSection(i, pageSize, done)
}

for i := 0; i < pll; i++ {
err := <-done
if err != nil {
return err
}
}

return nil
return <-done
}

0 comments on commit 56862e2

Please sign in to comment.