Update client.go

This commit is contained in:
风扇滑翔翼 2025-07-08 22:01:09 +08:00 committed by GitHub
parent ec4f48d429
commit fd71c36e2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}