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 <james@tailscale.com>
raggi/heartbeat-timebomb
James Tucker 2023-06-14 10:32:36 -07:00
parent c783f28228
commit 0fd6bf0a1c
No known key found for this signature in database
1 changed files with 4 additions and 1 deletions

View File

@ -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.