Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ func (c *Cron) run() {

// Handle system time moving backwards (NTP correction, VM snapshot restore).
// If Prev is in the future relative to now, time moved backwards.
for _, e := range c.entries {
// Iterate over a copy since Update() reorders the heap.
entriesCopy := make([]*Entry, len(c.entries))
copy(entriesCopy, c.entries)
for _, e := range entriesCopy {
if !e.Prev.IsZero() && e.Prev.After(now) {
e.Next = e.Schedule.Next(now)
c.entries.Update(e)
Expand Down
Loading