From cddf60537d367d1db84bc39b95282d7d36941116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 2 Apr 2024 22:53:47 +0800 Subject: [PATCH] Fix timer usage for monitor check update --- monitor_shared.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/monitor_shared.go b/monitor_shared.go index f286657..0cf80fe 100644 --- a/monitor_shared.go +++ b/monitor_shared.go @@ -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() {