account: fix timer leak

This commit is contained in:
islishude 2020-02-01 10:08:21 +08:00
parent 15d09038a6
commit 61fa179dd5

View file

@ -185,13 +185,16 @@ func (w *wallet) heartbeat() {
errc chan error errc chan error
err error err error
) )
timer := time.NewTicker(heartbeatCycle)
defer timer.Stop()
for errc == nil && err == nil { for errc == nil && err == nil {
// Wait until termination is requested or the heartbeat cycle arrives // Wait until termination is requested or the heartbeat cycle arrives
select { select {
case errc = <-w.healthQuit: case errc = <-w.healthQuit:
// Termination requested // Termination requested
continue continue
case <-time.After(heartbeatCycle): case <-timer.C:
// Heartbeat time // Heartbeat time
} }
// Execute a tiny data exchange to see responsiveness // Execute a tiny data exchange to see responsiveness