Say the held-list state on a part's first pass, so a warning raised before a restart is cleared
mesh/delivery merged: source.main moved to novox/mesh-delivery@1d416827157d
mesh/check being carried to ce600df98afc on 1d416827157d
mesh/delivery merged: source.main moved to novox/mesh-delivery@1d416827157d
mesh/check being carried to ce600df98afc on 1d416827157d
This commit is contained in:
@@ -1004,6 +1004,15 @@ func TestGrants(t *testing.T) {
|
||||
if last := said[len(said)-1]; last.Key != grants.HeldCondition || last.State != asks.StateCleared {
|
||||
t.Errorf("the held warning is not cleared once nothing is held: %+v", last)
|
||||
}
|
||||
// A part started while the warning stood (the said state is in memory only) clears it on its first pass.
|
||||
var fresh []asks.Condition
|
||||
fp := partOn(b)
|
||||
fp.Objects = p.Objects
|
||||
fp.Asker, fp.Say = fa, func(c asks.Condition) error { fresh = append(fresh, c); return nil }
|
||||
fp.Compose()
|
||||
if len(fresh) == 0 || fresh[0].Key != grants.HeldCondition || fresh[0].State != asks.StateCleared {
|
||||
t.Errorf("a fresh part's first pass does not say the held warning is cleared: %+v", fresh)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -143,9 +143,12 @@ type Part struct {
|
||||
made creations
|
||||
// askSeen is the revision of the last ask to compose (KeyAsked) this part acted on.
|
||||
askSeen uint64
|
||||
// heldSaid is the reason of the held-list condition last said (empty: none raised); holdMu guards it.
|
||||
holdMu sync.Mutex
|
||||
heldSaid string
|
||||
// heldSaid is the reason of the held-list condition last said (empty: none raised); heldKnown is whether one was said
|
||||
// since the start, so the first pass after a start always says its state (a condition raised before a restart is cleared
|
||||
// by it). holdMu guards both.
|
||||
holdMu sync.Mutex
|
||||
heldSaid string
|
||||
heldKnown bool
|
||||
}
|
||||
|
||||
// Ask is the value of KeyAsked: a tool's ask to compose now, and, from grants_assert, to create one module's missing
|
||||
|
||||
@@ -155,7 +155,7 @@ func (p *Part) sayHeld(why string) {
|
||||
}
|
||||
p.holdMu.Lock()
|
||||
defer p.holdMu.Unlock()
|
||||
if why == p.heldSaid {
|
||||
if p.heldKnown && why == p.heldSaid {
|
||||
return
|
||||
}
|
||||
c := asks.Condition{Key: HeldCondition, Subject: asks.Scope{Scope: "module", ID: "mesh-grants"}}
|
||||
@@ -169,7 +169,7 @@ func (p *Part) sayHeld(why string) {
|
||||
c.Resolved = "a pass finds nothing to hold back and the list advances"
|
||||
}
|
||||
if p.Say(c) == nil {
|
||||
p.heldSaid = why
|
||||
p.heldSaid, p.heldKnown = why, true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user