From 8f6ea671c6459e2b8e4739def505910eea0d191d Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 27 Jun 2022 01:05:44 +0400 Subject: [PATCH] Made use of mutex in a goroutine that cleans expired captchas. --- pkg/captcha/db.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/captcha/db.go b/pkg/captcha/db.go index c58da36..e8963b4 100644 --- a/pkg/captcha/db.go +++ b/pkg/captcha/db.go @@ -55,6 +55,8 @@ func (cdb *CaptchaDB) SetExpiry(expire time.Duration) { for id, captcha := range cdb.DB { if time.Now().Sub(captcha.Expiry()) <= 0 { + cdb.Lock() + defer cdb.Unlock() delete(cdb.DB, id) } }