fix potential memory leak with time.After

This commit is contained in:
Hayden 2023-03-21 10:52:17 -08:00
parent 975e636fb6
commit 40f4bd069e
No known key found for this signature in database
GPG key ID: 17CF79474E257545

View file

@ -37,8 +37,11 @@ func new(conf *config.Config) *app {
}
func (a *app) startBgTask(t time.Duration, fn func()) {
timer := time.NewTimer(t)
for {
timer.Reset(t)
a.server.Background(fn)
time.Sleep(t)
<-timer.C
}
}