From a4c3e2fbda57f40e625698efc9295915b5ae9035 Mon Sep 17 00:00:00 2001 From: Dominic Ferrando Date: Wed, 23 Apr 2025 21:27:03 -0400 Subject: [PATCH] Small mutex fix --- web/main.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/web/main.go b/web/main.go index 2ed5fc9..a17cc60 100644 --- a/web/main.go +++ b/web/main.go @@ -593,20 +593,22 @@ func main() { // ----------------- go func() { - for range time.Tick(10 * time.Minute) { + ticker := time.NewTicker(10 * time.Second) + defer ticker.Stop() + + for range ticker.C { util.CooldownMutex.Lock() - defer util.CooldownMutex.Unlock() - for ip, cooldown := range util.PostCooldowns { - if time.Since(cooldown) >= util.POST_COOLDOWN { + for ip, t := range util.PostCooldowns { + if time.Since(t) >= util.POST_COOLDOWN { delete(util.PostCooldowns, ip) } } - - for ip, cooldown := range util.ThreadCooldowns { - if time.Since(cooldown) >= util.THREAD_COOLDOWN { + for ip, t := range util.ThreadCooldowns { + if time.Since(t) >= util.THREAD_COOLDOWN { delete(util.ThreadCooldowns, ip) } } + util.CooldownMutex.Unlock() } }()