diff options
author | 2020-03-20 05:05:09 -0400 | |
---|---|---|
committer | 2020-03-20 10:05:09 +0100 | |
commit | 40c7b9174b1da59febc30a314d7ad01c48775a77 (patch) | |
tree | cd95c7cb9592a58329097499edf7d4871dee2047 /plugin/cache/handler.go | |
parent | d18b48e36c271de694563873fec108bf9c74c34d (diff) | |
download | coredns-40c7b9174b1da59febc30a314d7ad01c48775a77.tar.gz coredns-40c7b9174b1da59febc30a314d7ad01c48775a77.tar.zst coredns-40c7b9174b1da59febc30a314d7ad01c48775a77.zip |
plugin/cache: fix negative cache masking cases (#3744)
* fix negative cache masking cases
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* remove unecessary param
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/cache/handler.go')
-rw-r--r-- | plugin/cache/handler.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/plugin/cache/handler.go b/plugin/cache/handler.go index 2a64f11e4..0adc81576 100644 --- a/plugin/cache/handler.go +++ b/plugin/cache/handler.go @@ -31,7 +31,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) if i != nil { ttl = i.ttl(now) } - if i == nil || -ttl >= int(c.staleUpTo.Seconds()) { + if i == nil { crr := &ResponseWriter{ResponseWriter: w, Cache: c, state: state, server: server} return plugin.NextOrFailure(c.Name(), c.Next, ctx, crr, r) } @@ -104,15 +104,15 @@ func (c *Cache) getIgnoreTTL(now time.Time, state request.Request, server string ttl := i.(*item).ttl(now) if ttl > 0 || (c.staleUpTo > 0 && -ttl < int(c.staleUpTo.Seconds())) { cacheHits.WithLabelValues(server, Denial).Inc() + return i.(*item) } - return i.(*item) } if i, ok := c.pcache.Get(k); ok { ttl := i.(*item).ttl(now) if ttl > 0 || (c.staleUpTo > 0 && -ttl < int(c.staleUpTo.Seconds())) { cacheHits.WithLabelValues(server, Success).Inc() + return i.(*item) } - return i.(*item) } cacheMisses.WithLabelValues(server).Inc() return nil |