mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-02-21 14:06:52 +08:00
fix: hold closedM for both ReportLog and ReportState in RunDaemon
After Close() sets r.closed, the daemon should make zero network calls. Move ReportLog(false) under the same closedM guard as ReportState() so the daemon skips both when closed. This also simplifies RunDaemon by using a single lock/unlock pair. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -178,26 +178,20 @@ func (r *Reporter) Fire(entry *log.Entry) error {
|
||||
}
|
||||
|
||||
func (r *Reporter) RunDaemon() {
|
||||
r.closedM.Lock()
|
||||
if r.closed {
|
||||
r.closedM.Unlock()
|
||||
return
|
||||
}
|
||||
r.closedM.Unlock()
|
||||
|
||||
if r.ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_ = r.ReportLog(false)
|
||||
|
||||
r.closedM.Lock()
|
||||
defer r.closedM.Unlock()
|
||||
|
||||
if !r.closed {
|
||||
_ = r.ReportState()
|
||||
if r.closed {
|
||||
return
|
||||
}
|
||||
|
||||
_ = r.ReportLog(false)
|
||||
_ = r.ReportState()
|
||||
|
||||
time.AfterFunc(time.Second, r.RunDaemon)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user