Skip to content

Commit 228b81a

Browse files
wxiaoguangGiteaBot
authored andcommitted
Fix data-race bug when accessing task.LastRun (go-gitea#27584)
1 parent 7ec7c73 commit 228b81a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

services/cron/cron.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,11 @@ func ListTasks() TaskTable {
107107
prev = e.PreviousRun()
108108
}
109109

110+
task.lock.Lock()
110111
// If the manual run is after the cron run, use that instead.
111112
if prev.Before(task.LastRun) {
112113
prev = task.LastRun
113114
}
114-
115-
task.lock.Lock()
116115
tTable = append(tTable, &TaskTableRow{
117116
Name: task.Name,
118117
Spec: spec,

0 commit comments

Comments
 (0)