mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-05 17:10:30 +00:00
fix potential memory leak with time.After
This commit is contained in:
parent
975e636fb6
commit
40f4bd069e
1 changed files with 4 additions and 1 deletions
|
@ -37,8 +37,11 @@ func new(conf *config.Config) *app {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *app) startBgTask(t time.Duration, fn func()) {
|
func (a *app) startBgTask(t time.Duration, fn func()) {
|
||||||
|
timer := time.NewTimer(t)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
timer.Reset(t)
|
||||||
a.server.Background(fn)
|
a.server.Background(fn)
|
||||||
time.Sleep(t)
|
<-timer.C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue