diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-04-18 03:10:37 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-04-18 03:10:37 +0900 |
| commit | 27b1aaae386578caadcdc2d34b7e1b5d78374efc (patch) | |
| tree | e90c648f64511547be7c7e35795ff1840d81cff3 /internal/pkg/pkg.go | |
| parent | 9e18de1dc2fb195872b8d0d39e2924b110c43054 (diff) | |
internal/pkg: pending error alongside done channel
This significantly simplifies synchronisation of access to identErr.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/pkg.go')
| -rw-r--r-- | internal/pkg/pkg.go | 5 |
1 files changed, 4 insertions, 1 deletions
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 |
