From ba0b3c55bb51e2c4c53ebd8bebe42223f23bf14d Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 3 Jun 2026 01:07:22 +0800 Subject: [PATCH] fix(loadbalance): prevent double-close panic in SlowStartManager.Stop() Use atomic Swap instead of Load+close to prevent concurrent Stop() calls from both passing the check and closing the channel twice. --- internal/loadbalance/slow_start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/loadbalance/slow_start.go b/internal/loadbalance/slow_start.go index a8c8d8b..2a063d8 100644 --- a/internal/loadbalance/slow_start.go +++ b/internal/loadbalance/slow_start.go @@ -105,7 +105,7 @@ func (m *SlowStartManager) Start() { // Stop 停止后台更新。 func (m *SlowStartManager) Stop() { - if !m.running.Load() { + if !m.running.Swap(false) { return } close(m.stopCh)