mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-25 16:25:02 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,6 @@ type Reporter struct {
|
||||
cancel context.CancelFunc
|
||||
|
||||
closed bool
|
||||
closedM sync.Mutex
|
||||
|
||||
client client.Client
|
||||
clientM sync.Mutex
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user