From 5019cc090ed7cafb76643f964a76b1e97aee2985 Mon Sep 17 00:00:00 2001 From: Chenx Dust Date: Sat, 19 Sep 2026 22:02:11 +0800 Subject: [PATCH] fix: potential race condition in c.idleSession.Len() in idleCleanupExpTime() for anytls (#3225) --- transport/anytls/session/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport/anytls/session/client.go b/transport/anytls/session/client.go index 2e0385579..e3626bf93 100644 --- a/transport/anytls/session/client.go +++ b/transport/anytls/session/client.go @@ -174,9 +174,10 @@ func (c *Client) idleCleanup() { func (c *Client) idleCleanupExpTime(expTime time.Time) { activeCount := 0 - sessionToClose := make([]*Session, 0, c.idleSession.Len()) c.idleSessionLock.Lock() + sessionToClose := make([]*Session, 0, c.idleSession.Len()) + it := c.idleSession.Iterate() for it.IsNotEnd() { session := it.Value()