mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-07 21:09:52 +00:00
fix: udpSessionManager.mutex reentrant by cleanup
This commit is contained in:
parent
931fc2fdb2
commit
dc023ae13a
@ -262,16 +262,21 @@ func (m *udpSessionManager) idleCleanupLoop(stopCh <-chan struct{}) {
|
||||
|
||||
func (m *udpSessionManager) cleanup(idleOnly bool) {
|
||||
// We use RLock here as we are only scanning the map, not deleting from it.
|
||||
m.mutex.RLock()
|
||||
defer m.mutex.RUnlock()
|
||||
timeoutEntry := make([]*udpSessionEntry, 0, len(m.m))
|
||||
|
||||
m.mutex.RLock()
|
||||
now := time.Now()
|
||||
for _, entry := range m.m {
|
||||
if !idleOnly || now.Sub(entry.Last.Get()) > m.idleTimeout {
|
||||
entry.MarkTimeout()
|
||||
// Entry will be removed by its ExitFunc.
|
||||
timeoutEntry = append(timeoutEntry, entry)
|
||||
}
|
||||
}
|
||||
m.mutex.RUnlock()
|
||||
|
||||
for _, entry := range timeoutEntry {
|
||||
entry.MarkTimeout()
|
||||
// Entry will be removed by its ExitFunc.
|
||||
}
|
||||
}
|
||||
|
||||
func (m *udpSessionManager) feed(msg *protocol.UDPMessage) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user