Skip to content

Commit

Permalink
fix: mutex now convers writes to ValueReference if they happen
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 authored and daveshanley committed Jun 30, 2023
1 parent f77a8f6 commit 9e487a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions datamodel/high/base/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,13 @@ func NewSchema(schema *base.Schema) *Schema {
}

completeChildren := 0
completedProps := 0
totalProps := len(schema.DependentSchemas.Value) + len(schema.PatternProperties.Value)
if totalProps+children > 0 {
if children > 0 {
allDone:
for true {
select {
case <-polyCompletedChan:
completeChildren++
if totalProps == completedProps && children == completeChildren {
if children == completeChildren {
break allDone
}
}
Expand Down
4 changes: 2 additions & 2 deletions what-changed/model/comparison_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ func CheckMapForChangesWithComp[T any, R any](expLeft, expRight map[low.KeyRefer
checkLeft := func(k string, doneChan chan bool, f, g map[string]string, p, h map[string]low.ValueReference[T]) {
rhash := g[k]
if rhash == "" {
chLock.Lock()
if p[k].GetValueNode().Value == "" {
p[k].GetValueNode().Value = k
}
chLock.Lock()
CreateChange(changes, ObjectRemoved, label,
p[k].GetValueNode(), nil, true,
p[k].GetValue(), nil)
Expand Down Expand Up @@ -293,10 +293,10 @@ func checkRightValue[T any](k string, doneChan chan bool, f map[string]string, p

lhash := f[k]
if lhash == "" {
lock.Lock()
if p[k].GetValueNode().Value == "" {
p[k].GetValueNode().Value = k // this is kinda dirty, but I don't want to duplicate code so sue me.
}
lock.Lock()
CreateChange(changes, ObjectAdded, label,
nil, p[k].GetValueNode(), false,
nil, p[k].GetValue())
Expand Down

0 comments on commit 9e487a8

Please sign in to comment.