mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
Cleaned up what-changed race condition issues #165
A few small async issues needed attention. Signed-off-by: Quobix <dave@quobix.com>
This commit is contained in:
@@ -19,6 +19,8 @@ const (
|
||||
EMPTY_STR = ""
|
||||
)
|
||||
|
||||
var changeMutex sync.Mutex
|
||||
|
||||
// CreateChange is a generic function that will create a Change of type T, populate all properties if set, and then
|
||||
// add a pointer to Change[T] in the slice of Change pointers provided
|
||||
func CreateChange(changes *[]*Change, changeType int, property string, leftValueNode, rightValueNode *yaml.Node,
|
||||
@@ -45,7 +47,9 @@ func CreateChange(changes *[]*Change, changeType int, property string, leftValue
|
||||
c.NewObject = newObject
|
||||
|
||||
// add the change to supplied changes slice
|
||||
changeMutex.Lock()
|
||||
*changes = append(*changes, c)
|
||||
changeMutex.Unlock()
|
||||
return changes
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user