Made use of mutex in a goroutine that cleans expired captchas.

This commit is contained in:
Alexander Andreev 2022-06-27 01:05:44 +04:00
parent b0d5f9d9d0
commit 8f6ea671c6
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -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)
}
}