live_tracker: wrap add functions with mutex am: ff04c33f2a am: 5e8c2df08f

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2592646

Change-Id: I5fbefbef2f13119dcfa4f014efaa381500349a18
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
LaMont Jones 2023-05-22 18:14:06 +00:00 committed by Automerger Merge Worker
commit cbc5498930

View file

@ -44,46 +44,46 @@ func (l *liveTracker) AddBuildDefDeps(def *buildDef) error {
l.Lock() l.Lock()
defer l.Unlock() defer l.Unlock()
ruleDef, err := l.addRule(def.Rule) ruleDef, err := l.innerAddRule(def.Rule)
if err != nil { if err != nil {
return err return err
} }
def.RuleDef = ruleDef def.RuleDef = ruleDef
err = l.addNinjaStringListDeps(def.Outputs) err = l.innerAddNinjaStringListDeps(def.Outputs)
if err != nil { if err != nil {
return err return err
} }
err = l.addNinjaStringListDeps(def.Inputs) err = l.innerAddNinjaStringListDeps(def.Inputs)
if err != nil { if err != nil {
return err return err
} }
err = l.addNinjaStringListDeps(def.Implicits) err = l.innerAddNinjaStringListDeps(def.Implicits)
if err != nil { if err != nil {
return err return err
} }
err = l.addNinjaStringListDeps(def.OrderOnly) err = l.innerAddNinjaStringListDeps(def.OrderOnly)
if err != nil { if err != nil {
return err return err
} }
err = l.addNinjaStringListDeps(def.Validations) err = l.innerAddNinjaStringListDeps(def.Validations)
if err != nil { if err != nil {
return err return err
} }
for _, value := range def.Variables { for _, value := range def.Variables {
err = l.addNinjaStringDeps(value) err = l.innerAddNinjaStringDeps(value)
if err != nil { if err != nil {
return err return err
} }
} }
for _, value := range def.Args { for _, value := range def.Args {
err = l.addNinjaStringDeps(value) err = l.innerAddNinjaStringDeps(value)
if err != nil { if err != nil {
return err return err
} }
@ -93,6 +93,12 @@ func (l *liveTracker) AddBuildDefDeps(def *buildDef) error {
} }
func (l *liveTracker) addRule(r Rule) (def *ruleDef, err error) { func (l *liveTracker) addRule(r Rule) (def *ruleDef, err error) {
l.Lock()
defer l.Unlock()
return l.innerAddRule(r)
}
func (l *liveTracker) innerAddRule(r Rule) (def *ruleDef, err error) {
def, ok := l.rules[r] def, ok := l.rules[r]
if !ok { if !ok {
def, err = r.def(l.config) def, err = r.def(l.config)
@ -105,24 +111,24 @@ func (l *liveTracker) addRule(r Rule) (def *ruleDef, err error) {
} }
if def.Pool != nil { if def.Pool != nil {
err = l.addPool(def.Pool) err = l.innerAddPool(def.Pool)
if err != nil { if err != nil {
return nil, err return nil, err
} }
} }
err = l.addNinjaStringListDeps(def.CommandDeps) err = l.innerAddNinjaStringListDeps(def.CommandDeps)
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = l.addNinjaStringListDeps(def.CommandOrderOnly) err = l.innerAddNinjaStringListDeps(def.CommandOrderOnly)
if err != nil { if err != nil {
return nil, err return nil, err
} }
for _, value := range def.Variables { for _, value := range def.Variables {
err = l.addNinjaStringDeps(value) err = l.innerAddNinjaStringDeps(value)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -135,6 +141,12 @@ func (l *liveTracker) addRule(r Rule) (def *ruleDef, err error) {
} }
func (l *liveTracker) addPool(p Pool) error { func (l *liveTracker) addPool(p Pool) error {
l.Lock()
defer l.Unlock()
return l.addPool(p)
}
func (l *liveTracker) innerAddPool(p Pool) error {
_, ok := l.pools[p] _, ok := l.pools[p]
if !ok { if !ok {
def, err := p.def(l.config) def, err := p.def(l.config)
@ -153,6 +165,12 @@ func (l *liveTracker) addPool(p Pool) error {
} }
func (l *liveTracker) addVariable(v Variable) error { func (l *liveTracker) addVariable(v Variable) error {
l.Lock()
defer l.Unlock()
return l.innerAddVariable(v)
}
func (l *liveTracker) innerAddVariable(v Variable) error {
_, ok := l.variables[v] _, ok := l.variables[v]
if !ok { if !ok {
ctx := &variableFuncContext{l.ctx} ctx := &variableFuncContext{l.ctx}
@ -170,7 +188,7 @@ func (l *liveTracker) addVariable(v Variable) error {
l.variables[v] = value l.variables[v] = value
err = l.addNinjaStringDeps(value) err = l.innerAddNinjaStringDeps(value)
if err != nil { if err != nil {
return err return err
} }
@ -180,8 +198,14 @@ func (l *liveTracker) addVariable(v Variable) error {
} }
func (l *liveTracker) addNinjaStringListDeps(list []ninjaString) error { func (l *liveTracker) addNinjaStringListDeps(list []ninjaString) error {
l.Lock()
defer l.Unlock()
return l.innerAddNinjaStringListDeps(list)
}
func (l *liveTracker) innerAddNinjaStringListDeps(list []ninjaString) error {
for _, str := range list { for _, str := range list {
err := l.addNinjaStringDeps(str) err := l.innerAddNinjaStringDeps(str)
if err != nil { if err != nil {
return err return err
} }
@ -190,8 +214,14 @@ func (l *liveTracker) addNinjaStringListDeps(list []ninjaString) error {
} }
func (l *liveTracker) addNinjaStringDeps(str ninjaString) error { func (l *liveTracker) addNinjaStringDeps(str ninjaString) error {
l.Lock()
defer l.Unlock()
return l.innerAddNinjaStringDeps(str)
}
func (l *liveTracker) innerAddNinjaStringDeps(str ninjaString) error {
for _, v := range str.Variables() { for _, v := range str.Variables() {
err := l.addVariable(v) err := l.innerAddVariable(v)
if err != nil { if err != nil {
return err return err
} }