Add a mutex for soong config var map writes.
Fixes: 207572723 Test: CI Change-Id: Ide4ca9961b8615186c3ab703c461b6ef53ef656e
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/parser"
|
"github.com/google/blueprint/parser"
|
||||||
@@ -239,10 +240,18 @@ type Bp2BuildSoongConfigDefinitions struct {
|
|||||||
ValueVars map[string]bool
|
ValueVars map[string]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bp2buildSoongConfigVarsLock sync.Mutex
|
||||||
|
|
||||||
// SoongConfigVariablesForBp2build extracts information from a
|
// SoongConfigVariablesForBp2build extracts information from a
|
||||||
// SoongConfigDefinition that bp2build needs to generate constraint settings and
|
// SoongConfigDefinition that bp2build needs to generate constraint settings and
|
||||||
// values for, in order to migrate soong_config_module_type usages to Bazel.
|
// values for, in order to migrate soong_config_module_type usages to Bazel.
|
||||||
func (defs *Bp2BuildSoongConfigDefinitions) AddVars(mtDef SoongConfigDefinition) {
|
func (defs *Bp2BuildSoongConfigDefinitions) AddVars(mtDef SoongConfigDefinition) {
|
||||||
|
// In bp2build mode, this method is called concurrently in goroutines from
|
||||||
|
// loadhooks while parsing soong_config_module_type, so add a mutex to
|
||||||
|
// prevent concurrent map writes. See b/207572723
|
||||||
|
bp2buildSoongConfigVarsLock.Lock()
|
||||||
|
defer bp2buildSoongConfigVarsLock.Unlock()
|
||||||
|
|
||||||
if defs.StringVars == nil {
|
if defs.StringVars == nil {
|
||||||
defs.StringVars = make(map[string]map[string]bool)
|
defs.StringVars = make(map[string]map[string]bool)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user