Skip to content

Commit

Permalink
Fix timer usage for monitor check update
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Apr 2, 2024
1 parent 8bfb64c commit cddf605
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions monitor_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ func (m *defaultInterfaceMonitor) Start() error {
}

func (m *defaultInterfaceMonitor) delayCheckUpdate() {
if m.checkUpdateTimer != nil {
m.checkUpdateTimer.Stop()
if m.checkUpdateTimer == nil {
m.checkUpdateTimer = time.AfterFunc(time.Second, m.postCheckUpdate)
} else {
m.checkUpdateTimer.Reset(time.Second)
}
m.checkUpdateTimer = time.AfterFunc(time.Second, m.postCheckUpdate)
}

func (m *defaultInterfaceMonitor) postCheckUpdate() {
Expand Down

0 comments on commit cddf605

Please sign in to comment.