From 2c433852f784c14676944466d63d6803fbb66392 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Mon, 6 Nov 2023 18:13:13 +0100 Subject: [PATCH] swarm: fix timer Leak in the dial loop (#2636) --- p2p/net/swarm/dial_worker.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/p2p/net/swarm/dial_worker.go b/p2p/net/swarm/dial_worker.go index 6d6dcf65a..0cac6e4fa 100644 --- a/p2p/net/swarm/dial_worker.go +++ b/p2p/net/swarm/dial_worker.go @@ -120,6 +120,8 @@ func (w *dialWorker) loop() { startTime := w.cl.Now() // dialTimer is the dialTimer used to trigger dials dialTimer := w.cl.InstantTimer(startTime.Add(math.MaxInt64)) + defer dialTimer.Stop() + timerRunning := true // scheduleNextDial updates timer for triggering the next dial scheduleNextDial := func() {