diff --git a/modules/mesh-vault/cmd/mesh-vault/main.go b/modules/mesh-vault/cmd/mesh-vault/main.go index 3333b3c0b..63ba03a1b 100644 --- a/modules/mesh-vault/cmd/mesh-vault/main.go +++ b/modules/mesh-vault/cmd/mesh-vault/main.go @@ -302,9 +302,20 @@ func readPlanRaw(key string) ([]byte, error) { // assignmentKeys is every key of the controller's assignments mirror, read the same way. func assignmentKeys() ([]string, error) { return stdio.State(AssignmentsRead).Keys() } +// Checked by TestTheVaultWholeRotatesANodesLoginWithAStandInEngine: the race it met (a pass before Serve, every watch +// refused, the rotation waiting for the minute's pass) is what this closes. +// afterServed runs f once served is closed, that is once stdio.Serve holds the runtime's channel: every function of the +// bus refuses before that ("before Serve"), and a watch refused then waits for the minute's pass. +func afterServed(served <-chan struct{}, f func()) { + go func() { + <-served + f() + }() +} + func main() { env := build() - go func() { + afterServed(stdio.Served(), func() { tick := time.NewTicker(time.Minute) defer tick.Stop() // At start, every covered account it holds whose hash is not of its current generation (ADR 0547 clause 9). @@ -361,7 +372,7 @@ func main() { } <-tick.C } - }() + }) if err := stdio.Serve("", tools(env)); err != nil { say("%v", err) os.Exit(1)