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 }