Actually pause mutators when adding dependencies (#335)

In the coordination between #316 and #318 the calls to mctx.pause()
were forgotten, causing dependencies returned by the Add*Dependency
calls to be in an undefined state.  Add the missing calls to
mctx.pause().

Change-Id: I648ad269449777363801785059b13b866424d4b5
This commit is contained in:
colincross 2020-12-14 11:23:23 -08:00 committed by GitHub
parent 9ae14f12f9
commit cfa2e91dc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1102,7 +1102,9 @@ func (mctx *mutatorContext) AddDependency(module Module, tag DependencyTag, deps
if len(errs) > 0 {
mctx.errs = append(mctx.errs, errs...)
}
depInfos = append(depInfos, maybeLogicModule(depInfo))
if mctx.pause(depInfo) {
depInfos = append(depInfos, maybeLogicModule(depInfo))
}
}
return depInfos
}
@ -1133,7 +1135,9 @@ func (mctx *mutatorContext) AddVariationDependencies(variations []Variation, tag
if len(errs) > 0 {
mctx.errs = append(mctx.errs, errs...)
}
depInfos = append(depInfos, maybeLogicModule(depInfo))
if mctx.pause(depInfo) {
depInfos = append(depInfos, maybeLogicModule(depInfo))
}
}
return depInfos
}
@ -1147,7 +1151,9 @@ func (mctx *mutatorContext) AddFarVariationDependencies(variations []Variation,
if len(errs) > 0 {
mctx.errs = append(mctx.errs, errs...)
}
depInfos = append(depInfos, maybeLogicModule(depInfo))
if mctx.pause(depInfo) {
depInfos = append(depInfos, maybeLogicModule(depInfo))
}
}
return depInfos
}
@ -1202,16 +1208,19 @@ func (mctx *mutatorContext) CreateModule(factory ModuleFactory, props ...interfa
// pause waits until the given dependency has been visited by the mutator's parallelVisit call.
// It returns true if the pause was supported, false if the pause was not supported and did not
// occur, which will happen when the mutator is not parallelizable.
// occur, which will happen when the mutator is not parallelizable. If the dependency is nil
// it returns true if pausing is supported or false if it is not.
func (mctx *mutatorContext) pause(dep *moduleInfo) bool {
if mctx.pauseCh != nil {
unpause := make(unpause)
mctx.pauseCh <- pauseSpec{
paused: mctx.module,
until: dep,
unpause: unpause,
if dep != nil {
unpause := make(unpause)
mctx.pauseCh <- pauseSpec{
paused: mctx.module,
until: dep,
unpause: unpause,
}
<-unpause
}
<-unpause
return true
}
return false