fix: mutex now convers writes to ValueReference if they happen

This commit is contained in:
Derrick J. Wippler
2023-06-22 13:49:09 -05:00
committed by quobix
parent f77a8f6f2a
commit 9e487a8c49
2 changed files with 4 additions and 6 deletions

View File

@@ -431,15 +431,13 @@ func NewSchema(schema *base.Schema) *Schema {
} }
completeChildren := 0 completeChildren := 0
completedProps := 0 if children > 0 {
totalProps := len(schema.DependentSchemas.Value) + len(schema.PatternProperties.Value)
if totalProps+children > 0 {
allDone: allDone:
for true { for true {
select { select {
case <-polyCompletedChan: case <-polyCompletedChan:
completeChildren++ completeChildren++
if totalProps == completedProps && children == completeChildren { if children == completeChildren {
break allDone break allDone
} }
} }

View File

@@ -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]) { checkLeft := func(k string, doneChan chan bool, f, g map[string]string, p, h map[string]low.ValueReference[T]) {
rhash := g[k] rhash := g[k]
if rhash == "" { if rhash == "" {
chLock.Lock()
if p[k].GetValueNode().Value == "" { if p[k].GetValueNode().Value == "" {
p[k].GetValueNode().Value = k p[k].GetValueNode().Value = k
} }
chLock.Lock()
CreateChange(changes, ObjectRemoved, label, CreateChange(changes, ObjectRemoved, label,
p[k].GetValueNode(), nil, true, p[k].GetValueNode(), nil, true,
p[k].GetValue(), nil) p[k].GetValue(), nil)
@@ -293,10 +293,10 @@ func checkRightValue[T any](k string, doneChan chan bool, f map[string]string, p
lhash := f[k] lhash := f[k]
if lhash == "" { if lhash == "" {
lock.Lock()
if p[k].GetValueNode().Value == "" { 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. 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, CreateChange(changes, ObjectAdded, label,
nil, p[k].GetValueNode(), false, nil, p[k].GetValueNode(), false,
nil, p[k].GetValue()) nil, p[k].GetValue())