From f14c548451b5ee99cacc9062a6e1c6104466278a 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:18:24 +0800 Subject: [PATCH] Update session.go --- common/mux/session.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/mux/session.go b/common/mux/session.go index 1530a661..f5ca30a3 100644 --- a/common/mux/session.go +++ b/common/mux/session.go @@ -50,11 +50,13 @@ func (m *SessionManager) Count() int { return int(m.count) } -func (m *SessionManager) Allocate(MaxConcurrency int) *Session { +func (m *SessionManager) Allocate(Strategy ClientStrategy) *Session { + MaxConcurrency := int(Strategy.MaxConcurrency) + MaxConnection := uint16(Strategy.MaxConnection) m.Lock() defer m.Unlock() - if m.closed || (MaxConcurrency > 0 && len(m.sessions) >= MaxConcurrency) { + if m.closed || (MaxConcurrency > 0 && len(m.sessions) >= MaxConcurrency) || (MaxConnection > 0 && m.count >= MaxConnection) { return nil }