Replace time.After with time.NewTimer (#12945)
time.After might leave stray timers if other channels in select triggered early Signed-off-by: Alexander Morozov <lk4d4math@gmail.com>
Этот коммит содержится в:
коммит произвёл
Claudio Costa
родитель
a3257690d6
Коммит
9b9923ea42
@@ -86,11 +86,13 @@ func (schedulers *Schedulers) Start() *Schedulers {
|
||||
}
|
||||
|
||||
for {
|
||||
timer := time.NewTimer(1 * time.Minute)
|
||||
select {
|
||||
case <-schedulers.stop:
|
||||
mlog.Debug("Schedulers received stop signal.")
|
||||
timer.Stop()
|
||||
return
|
||||
case now = <-time.After(1 * time.Minute):
|
||||
case now = <-timer.C:
|
||||
cfg := schedulers.jobs.Config()
|
||||
|
||||
for idx, nextTime := range schedulers.nextRunTimes {
|
||||
@@ -128,6 +130,7 @@ func (schedulers *Schedulers) Start() *Schedulers {
|
||||
}
|
||||
}
|
||||
}
|
||||
timer.Stop()
|
||||
}
|
||||
})
|
||||
}()
|
||||
|
||||
Ссылка в новой задаче
Block a user