From fd71c36e2c49f1638f7cbcfb970f30a852535891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 8 Jul 2025 22:01:09 +0800 Subject: [PATCH] Update client.go --- common/mux/client.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/mux/client.go b/common/mux/client.go index b6148fbc..f73fc509 100644 --- a/common/mux/client.go +++ b/common/mux/client.go @@ -174,7 +174,6 @@ type ClientWorker struct { link transport.Link done *done.Instance strategy ClientStrategy - access sync.Mutex } var ( @@ -277,6 +276,8 @@ func (m *ClientWorker) IsClosing() bool { return false } +// IsFull returns true if this ClientWorker is unable to accept more connections. +// it might be because it is closing, or the number of connections has reached the limit. func (m *ClientWorker) IsFull() bool { if m.IsClosing() || m.Closed() { return true @@ -290,14 +291,12 @@ func (m *ClientWorker) IsFull() bool { } func (m *ClientWorker) Dispatch(ctx context.Context, link *transport.Link) bool { - m.access.Lock() - defer m.access.Unlock() if m.IsFull() { return false } sm := m.sessionManager - s := sm.Allocate() + s := sm.Allocate(int(m.strategy.MaxConcurrency)) if s == nil { return false }