mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-24 15:55:03 +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:
@@ -25,10 +25,9 @@ type Reporter struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
|
|
||||||
closed bool
|
closed bool
|
||||||
closedM sync.Mutex
|
|
||||||
|
|
||||||
client client.Client
|
client client.Client
|
||||||
clientM sync.Mutex
|
clientM sync.Mutex
|
||||||
|
|
||||||
logOffset int
|
logOffset int
|
||||||
@@ -182,10 +181,11 @@ func (r *Reporter) RunDaemon() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r.closedM.Lock()
|
r.stateMu.RLock()
|
||||||
defer r.closedM.Unlock()
|
closed := r.closed
|
||||||
|
r.stateMu.RUnlock()
|
||||||
|
|
||||||
if r.closed {
|
if closed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,11 +232,8 @@ func (r *Reporter) SetOutputs(outputs map[string]string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reporter) Close(lastWords string) error {
|
func (r *Reporter) Close(lastWords string) error {
|
||||||
r.closedM.Lock()
|
|
||||||
r.closed = true
|
|
||||||
r.closedM.Unlock()
|
|
||||||
|
|
||||||
r.stateMu.Lock()
|
r.stateMu.Lock()
|
||||||
|
r.closed = true
|
||||||
if r.state.Result == runnerv1.Result_RESULT_UNSPECIFIED {
|
if r.state.Result == runnerv1.Result_RESULT_UNSPECIFIED {
|
||||||
if lastWords == "" {
|
if lastWords == "" {
|
||||||
lastWords = "Early termination"
|
lastWords = "Early termination"
|
||||||
|
|||||||
Reference in New Issue
Block a user