aboutsummaryrefslogtreecommitdiff
path: root/cmd/anubis/decaymap.go
AgeCommit message (Collapse)AuthorFilesLines
2025-04-26feat(anubis): replace with tombstoneXe Iaso1-61/+0
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-01cmd/anubis: Fix potential decaymap race (#683)Em Sharnoff1-1/+5
Fixes a potential TOCTOU issue that would cause values to be spuriously erased. IIUC, the following interleaving of (*DecayMap).Get() and (*DecayMap).Set() can cause an update to be erased: // thread A: Get("x") m.lock.RLock() value, ok := m.data["x"] m.lock.RUnlock() ... if time.Now().After(value.expiry) { // <wait for lock!> // thread B: Set("x", ...) m.lock.Lock() defer m.lock.Unlock() m.data["x"] = DecayMapEntry{ ... } // thread A continues its Get("x") after acquring the lock: m.lock.Lock() delete(m.data, "x") // Oops! Newer entry is deleted! m.lock.Unlock() Realistically... I think it's probably a non-issue either way, because the worst that can happen is that a cache entry is spuriously removed, and it'll just get re-fetched.
2025-02-14cmd/anubis: cache DNSBL hits in a DecayMapXe Iaso1-0/+57
Signed-off-by: Xe Iaso <me@xeiaso.net>