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 }