mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-07 17:51:16 +08:00
session remove rewrited
This commit is contained in:
@@ -120,14 +120,17 @@ func (s *simpleSessionStater) GetSession(key interface{}) *stats.Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *simpleSessionStater) RemoveSession(key interface{}) {
|
func (s *simpleSessionStater) RemoveSession(key interface{}) {
|
||||||
s.mux.Lock()
|
|
||||||
defer s.mux.Unlock()
|
|
||||||
|
|
||||||
if sess, ok := s.sessions.Load(key); ok {
|
if sess, ok := s.sessions.Load(key); ok {
|
||||||
|
// move to completed sessions
|
||||||
|
s.mux.Lock()
|
||||||
s.completedSessions = append(s.completedSessions, *(sess.(*stats.Session)))
|
s.completedSessions = append(s.completedSessions, *(sess.(*stats.Session)))
|
||||||
if len(s.completedSessions) > maxCompletedSessions {
|
if len(s.completedSessions) > maxCompletedSessions {
|
||||||
s.completedSessions = s.completedSessions[1:]
|
s.completedSessions = s.completedSessions[1:]
|
||||||
}
|
}
|
||||||
|
s.mux.Unlock()
|
||||||
|
|
||||||
|
s.sessions.Delete(key)
|
||||||
|
} else {
|
||||||
|
log.Warnf("session key [%v] not found", key)
|
||||||
}
|
}
|
||||||
s.sessions.Delete(key)
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user