Made use of mutex in a goroutine that cleans expired captchas.
This commit is contained in:
parent
b0d5f9d9d0
commit
8f6ea671c6
@ -55,6 +55,8 @@ func (cdb *CaptchaDB) SetExpiry(expire time.Duration) {
|
|||||||
|
|
||||||
for id, captcha := range cdb.DB {
|
for id, captcha := range cdb.DB {
|
||||||
if time.Now().Sub(captcha.Expiry()) <= 0 {
|
if time.Now().Sub(captcha.Expiry()) <= 0 {
|
||||||
|
cdb.Lock()
|
||||||
|
defer cdb.Unlock()
|
||||||
delete(cdb.DB, id)
|
delete(cdb.DB, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user