mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-06-21 10:19:54 -04:00
bug fixes
This commit is contained in:
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
type SessionManager struct {
|
||||
sync.RWMutex
|
||||
count uint16
|
||||
sessions map[uint16]*Session
|
||||
count uint16
|
||||
closed bool
|
||||
}
|
||||
|
||||
@@ -27,6 +27,13 @@ func (m *SessionManager) Size() int {
|
||||
return len(m.sessions)
|
||||
}
|
||||
|
||||
func (m *SessionManager) Count() int {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
return int(m.count)
|
||||
}
|
||||
|
||||
func (m *SessionManager) Allocate() *Session {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
@@ -71,8 +78,8 @@ func (m *SessionManager) Get(id uint16) (*Session, bool) {
|
||||
}
|
||||
|
||||
func (m *SessionManager) CloseIfNoSession() bool {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
if m.closed {
|
||||
return true
|
||||
@@ -87,8 +94,8 @@ func (m *SessionManager) CloseIfNoSession() bool {
|
||||
}
|
||||
|
||||
func (m *SessionManager) Close() {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
if m.closed {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user