Skip to content

Commit

Permalink
Merge pull request #25 from HPInc/fix-prod
Browse files Browse the repository at this point in the history
Fix data race in ValidateCoherency
  • Loading branch information
qmuntal committed Apr 30, 2021
2 parents 686901c + 8ec6ed8 commit 8f9ae4d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,19 @@ func (m *Model) ValidateCoherency() error {
for path, c := range m.Childs {
wg.Add(len(c.Resources.Objects))
for i := range c.Resources.Objects {
go func(i int) {
go func(path string, i int) {
defer wg.Done()
r := c.Resources.Objects[i]
res := m.Childs[path].Resources
r := res.Objects[i]
if isSolidObject(r) {
err := r.Mesh.ValidateCoherency()
if err != nil {
mu.Lock()
errs = errors.Append(errs, errors.WrapPath(errors.WrapIndex(errors.Wrap(err, r.Mesh), r, i), c.Resources, path))
errs = errors.Append(errs, errors.WrapPath(errors.WrapIndex(errors.Wrap(err, r.Mesh), r, i), res, path))
mu.Unlock()
}
}
}(i)
}(path, i)
}
}
wg.Wait()
Expand Down

0 comments on commit 8f9ae4d

Please sign in to comment.