1
0
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:
Darien Raymond
2017-04-19 21:27:21 +02:00
parent 1d761e30a9
commit 6d7aaa6535
11 changed files with 46 additions and 52 deletions

View File

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