From 0fd6bf0a1c2f6d12d3debdad5e90ef7dd6403054 Mon Sep 17 00:00:00 2001 From: James Tucker Date: Wed, 14 Jun 2023 10:32:36 -0700 Subject: [PATCH] wgengine/magicsock: ensure that an existing timer is stopped There presently is not a bug here, but this is a time-bomb waiting for an innocent incremental change to accidentally adjust the parent call chain resulting in a timer leak. Updates #cleanup Signed-off-by: James Tucker --- wgengine/magicsock/magicsock.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index dea8b2d97..bdb328eea 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -4441,7 +4441,10 @@ func (de *endpoint) heartbeat() { de.mu.Lock() defer de.mu.Unlock() - de.heartBeatTimer = nil + if de.heartBeatTimer != nil { + de.heartBeatTimer.Stop() + de.heartBeatTimer = nil + } if de.heartbeatDisabled { // If control override to disable heartBeatTimer set, return early.