Count the take-ins and every other background work in the serving group, so serve's stop waits for them too (issue 1945)

inBackground ran the take-ins of done keys (now in #463's slots), the start's
look, the given values' replacement and the announced reads beside serve without
serve waiting for them: a take-in could outlive its controller as the loops did.
It now takes the context and is counted in its serving group as well, and a
serve that is stopping starts none.
This commit is contained in:
2026-10-25 16:36:49 +01:00
parent c7e31640cf
commit cc5c9ae888
6 changed files with 22 additions and 18 deletions
+3 -3
View File
@@ -307,7 +307,7 @@ func watchDoneKeys(ctx context.Context, open *stores) {
return
}
if err := builderkeys.Watch(ctx, keys.JS, func(module string) {
inBackground(func() { takeDoneKey(ctx, open, module) })
inBackground(ctx, func() { takeDoneKey(ctx, open, module) })
}); err != nil {
closeKeys()
fmt.Printf("done keys: the builder's keys are not watched: %v\n", err)
@@ -318,7 +318,7 @@ func watchDoneKeys(ctx context.Context, open *stores) {
closeKeys()
})
// And every module once now, after the watch is open so no write falls between the two.
inBackground(func() {
inBackground(ctx, func() {
doneKeysAtStart(ctx, catalogedModules(open), func(module string) { takeDoneKeyAtStart(ctx, open, module) })
})
}
@@ -389,7 +389,7 @@ func takeDoneKeyAtStart(ctx context.Context, open *stores, module string) {
_, again := doneKeysLookAgain.LoadAndDelete(module)
if err != nil || again {
// A failure, a wait or a wake meanwhile is followed by takeDoneKey, which says it and looks again.
inBackground(func() { takeDoneKey(ctx, open, module) })
inBackground(ctx, func() { takeDoneKey(ctx, open, module) })
}
}