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 {
|
for {
|
||||||
|
timer := time.NewTimer(1 * time.Minute)
|
||||||
select {
|
select {
|
||||||
case <-schedulers.stop:
|
case <-schedulers.stop:
|
||||||
mlog.Debug("Schedulers received stop signal.")
|
mlog.Debug("Schedulers received stop signal.")
|
||||||
|
timer.Stop()
|
||||||
return
|
return
|
||||||
case now = <-time.After(1 * time.Minute):
|
case now = <-timer.C:
|
||||||
cfg := schedulers.jobs.Config()
|
cfg := schedulers.jobs.Config()
|
||||||
|
|
||||||
for idx, nextTime := range schedulers.nextRunTimes {
|
for idx, nextTime := range schedulers.nextRunTimes {
|
||||||
@@ -128,6 +130,7 @@ func (schedulers *Schedulers) Start() *Schedulers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
timer.Stop()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user