Monotonic time for stale removal

This commit is contained in:
Ian Gulliver
2020-11-25 20:13:39 +00:00
parent 650c835234
commit 6c4ec676fe

View File

@@ -189,11 +189,11 @@ func scan() {
mu.Lock() mu.Lock()
defer mu.Unlock() defer mu.Unlock()
cutoff := time.Now().UTC().Add(-30 * time.Second) grace := 30 * time.Second
for _, rm := range roomById { for _, rm := range roomById {
for _, c := range rm.clientById { for _, c := range rm.clientById {
if c.lastSeen.Before(cutoff) { if time.Now().Sub(c.lastSeen) > grace {
c.remove() c.remove()
} }
} }