Update session.go

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

View file

@ -50,11 +50,11 @@ func (m *SessionManager) Count() int {
return int(m.count)
}
func (m *SessionManager) Allocate() *Session {
func (m *SessionManager) Allocate(MaxConcurrency int) *Session {
m.Lock()
defer m.Unlock()
if m.closed {
if m.closed || (MaxConcurrency > 0 && len(m.sessions) >= MaxConcurrency) {
return nil
}