0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-25 14:02:58 +01:00

Fix data-race bug when accessing task.LastRun (#27584)

This commit is contained in:
wxiaoguang 2023-10-11 22:51:20 +08:00 committed by GitHub
parent fb74fe99d6
commit 1d155a43ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,12 +107,11 @@ func ListTasks() TaskTable {
prev = e.PreviousRun() prev = e.PreviousRun()
} }
task.lock.Lock()
// If the manual run is after the cron run, use that instead. // If the manual run is after the cron run, use that instead.
if prev.Before(task.LastRun) { if prev.Before(task.LastRun) {
prev = task.LastRun prev = task.LastRun
} }
task.lock.Lock()
tTable = append(tTable, &TaskTableRow{ tTable = append(tTable, &TaskTableRow{
Name: task.Name, Name: task.Name,
Spec: spec, Spec: spec,