mirror of
https://github.com/coredns/coredns.git
synced 2025-08-06 06:17:00 +02:00
fix(cache): data race when refreshing cached messages (#7398)
This commit is contained in:
parent
19b6b3cdb9
commit
ae5e03a94d
24
plugin/cache/cache.go
vendored
24
plugin/cache/cache.go
vendored
@ -199,6 +199,18 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
|
||||
duration = computeTTL(msgTTL, w.minpttl, w.pttl)
|
||||
}
|
||||
|
||||
// Apply capped TTL to this reply to avoid jarring TTL experience 1799 -> 8 (e.g.)
|
||||
ttl := uint32(duration.Seconds())
|
||||
res.Answer = filterRRSlice(res.Answer, ttl, false)
|
||||
res.Ns = filterRRSlice(res.Ns, ttl, false)
|
||||
res.Extra = filterRRSlice(res.Extra, ttl, false)
|
||||
|
||||
if !w.do && !w.ad {
|
||||
// unset AD bit if requester is not OK with DNSSEC
|
||||
// But retain AD bit if requester set the AD bit in the request, per RFC6840 5.7-5.8
|
||||
res.AuthenticatedData = false
|
||||
}
|
||||
|
||||
if hasKey && duration > 0 {
|
||||
if w.state.Match(res) {
|
||||
w.set(res, key, mt, duration)
|
||||
@ -214,18 +226,6 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Apply capped TTL to this reply to avoid jarring TTL experience 1799 -> 8 (e.g.)
|
||||
ttl := uint32(duration.Seconds())
|
||||
res.Answer = filterRRSlice(res.Answer, ttl, false)
|
||||
res.Ns = filterRRSlice(res.Ns, ttl, false)
|
||||
res.Extra = filterRRSlice(res.Extra, ttl, false)
|
||||
|
||||
if !w.do && !w.ad {
|
||||
// unset AD bit if requester is not OK with DNSSEC
|
||||
// But retain AD bit if requester set the AD bit in the request, per RFC6840 5.7-5.8
|
||||
res.AuthenticatedData = false
|
||||
}
|
||||
|
||||
return w.ResponseWriter.WriteMsg(res)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user