mirror of
https://github.com/apernet/hysteria.git
synced 2025-04-02 03:57:38 +03:00
fix: udpSessionManager.mutex reentrant by cleanup
This commit is contained in:
parent
931fc2fdb2
commit
dc023ae13a
1 changed files with 9 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue