From 64ab5fdd5125bbba46ebd9bb83cf36204a161a17 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 19 Feb 2026 03:20:13 +0100 Subject: [PATCH] fix: use stateMu instead of closedM to protect r.closed Remove the dedicated closedM mutex and use stateMu instead, since closed is part of the reporter state. RunDaemon reads r.closed under stateMu.RLock, Close sets it under the existing stateMu.Lock block. Co-Authored-By: Claude Opus 4.6 --- internal/pkg/report/reporter.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/pkg/report/reporter.go b/internal/pkg/report/reporter.go index d1b1569..9ead88e 100644 --- a/internal/pkg/report/reporter.go +++ b/internal/pkg/report/reporter.go @@ -25,10 +25,9 @@ type Reporter struct { ctx context.Context cancel context.CancelFunc - closed bool - closedM sync.Mutex + closed bool - client client.Client + client client.Client clientM sync.Mutex logOffset int @@ -182,10 +181,11 @@ func (r *Reporter) RunDaemon() { return } - r.closedM.Lock() - defer r.closedM.Unlock() + r.stateMu.RLock() + closed := r.closed + r.stateMu.RUnlock() - if r.closed { + if closed { return } @@ -232,11 +232,8 @@ func (r *Reporter) SetOutputs(outputs map[string]string) { } func (r *Reporter) Close(lastWords string) error { - r.closedM.Lock() - r.closed = true - r.closedM.Unlock() - r.stateMu.Lock() + r.closed = true if r.state.Result == runnerv1.Result_RESULT_UNSPECIFIED { if lastWords == "" { lastWords = "Early termination"