check closed again before scheduling another task

This commit is contained in:
Darien Raymond
2018-06-29 20:56:10 +02:00
parent 98e6254df8
commit 596d05bff5
+6 -1
View File
@@ -42,12 +42,17 @@ func (t *Periodic) checkedExecute() error {
}
t.access.Lock()
defer t.access.Unlock()
if t.closed {
return nil
}
t.timer = time.AfterFunc(t.Interval, func() {
if err := t.checkedExecute(); err != nil && t.OnError != nil {
t.OnError(err)
}
})
t.access.Unlock()
return nil
}