Skip to content

Commit

Permalink
Shorten caching for empty success responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Nov 30, 2020
1 parent 454a234 commit a60a53e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 0 additions & 4 deletions resolver/resolver-tcp.go
Expand Up @@ -479,10 +479,6 @@ func (mgr *tcpResolverConnMgr) handleQueryResponse(conn *dns.Conn, msg *dns.Msg)

// persist to database
rrCache := inFlight.MakeCacheRecord(msg)
if !rrCache.Cacheable() {
return
}

rrCache.Clean(minTTL)
err := rrCache.Save()
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions resolver/rrcache.go
Expand Up @@ -85,6 +85,12 @@ func (rrCache *RRCache) Clean(minExpires uint32) {
lowestTTL = maxTTL
}

// Adjust return code if there are no answers
if rrCache.RCode == dns.RcodeSuccess &&
len(rrCache.Answer) == 0 {
rrCache.RCode = dns.RcodeNameError
}

// shorten caching
switch {
case rrCache.RCode != dns.RcodeSuccess:
Expand Down

0 comments on commit a60a53e

Please sign in to comment.