internal/pkg: pending error alongside done channel
All checks were successful
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (push) Successful in 2m44s
Test / ShareFS (push) Successful in 3m48s
Test / Hakurei (push) Successful in 3m52s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hakurei (race detector) (push) Successful in 6m28s
Test / Flake checks (push) Successful in 1m20s

This significantly simplifies synchronisation of access to identErr.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-18 03:10:37 +09:00
parent 9e18de1dc2
commit 27b1aaae38

View File

@@ -560,6 +560,8 @@ func newToplevel(ctx context.Context) *toplevel {
type pendingCure struct {
// Closed on cure completion.
done <-chan struct{}
// Error outcome, safe to access after done is closed.
err error
// Cancels the corresponding cure.
cancel context.CancelFunc
}
@@ -1065,7 +1067,7 @@ func (c *Cache) loadOrStoreIdent(id unique.Handle[ID]) (
<-pending.done
c.identMu.RLock()
if checksum, ok = c.ident[id]; !ok {
err = c.identErr[id]
err = pending.err
}
c.identMu.RUnlock()
return
@@ -1091,6 +1093,7 @@ func (c *Cache) finaliseIdent(
) {
c.identMu.Lock()
if err != nil {
c.identPending[id].err = err
c.identErr[id] = err
} else {
c.ident[id] = checksum