Skip to content

Commit a659f8a

Browse files
committed
dnsx/cacher: rmv cached objs without answers
1 parent 3e74588 commit a659f8a

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

intra/dnsx/cacher.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,15 @@ func (t *ctransport) fetch(network string, q *dns.Msg, smmout *x.DNSSummary, cb
447447
log.D("cache: hit(k: %s / stale? %t / ans? %t): %s", key, !isfresh, hasans, v)
448448
r, cachedsmm, err := asResponse(q, v, isfresh) // return cached response, may be stale
449449
if err != nil {
450-
log.W("cache: hit(k: %s) %s, but err? %v", key, v, err)
451-
if err == errCacheResponseMismatch {
450+
nilOrMismatch := errors.Is(err, errNilCacheResponse) ||
451+
errors.Is(err, errCacheResponseMismatch)
452+
453+
logeif(nilOrMismatch)("cache: hit(k: %s) %s, but err? %v", key, v, err)
454+
455+
if nilOrMismatch {
452456
// FIXME: this is a hack to fix an issue where the cache
453-
// returns a response that does not match the fqdn in query.
457+
// returns a response that does not match the fqdn in query
458+
// or somehow has wrapper cache-obj but not the dns answer.
454459
cb.mu.Lock()
455460
delete(cb.c, key) // del the corrupted entry
456461
cb.mu.Unlock()

0 commit comments

Comments
 (0)