diff --git a/transport/internet/kcp/connection.go b/transport/internet/kcp/connection.go index 7c118a774..871e7aa8e 100644 --- a/transport/internet/kcp/connection.go +++ b/transport/internet/kcp/connection.go @@ -149,11 +149,12 @@ func (u *Updater) Run() { if u.shouldTerminate() { return } - interval := u.Interval() + ticker := time.NewTicker(u.Interval()) for u.shouldContinue() { u.updateFunc() - time.Sleep(interval) + <-ticker.C } + ticker.Stop() } }