From 27b1aaae386578caadcdc2d34b7e1b5d78374efc Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 18 Apr 2026 03:10:37 +0900 Subject: [PATCH] internal/pkg: pending error alongside done channel This significantly simplifies synchronisation of access to identErr. Signed-off-by: Ophestra --- internal/pkg/pkg.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index 36aa7a91..0ad39a4b 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -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