mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-08-10 20:05:02 +02: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 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
a4a6e291d5
commit
39cef65b52
@@ -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