mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
fix(cache): data race when updating the TTL of cached messages (#7397)
This commit is contained in:
6
plugin/cache/dnssec.go
vendored
6
plugin/cache/dnssec.go
vendored
@@ -3,8 +3,8 @@ package cache
|
|||||||
import "github.com/miekg/dns"
|
import "github.com/miekg/dns"
|
||||||
|
|
||||||
// filterRRSlice filters out OPT RRs, and sets all RR TTLs to ttl.
|
// filterRRSlice filters out OPT RRs, and sets all RR TTLs to ttl.
|
||||||
// If dup is true the RRs in rrs are _copied_ into the slice that is
|
// If dup is true the RRs in rrs are _copied_ before adjusting their
|
||||||
// returned.
|
// TTL and the slice of copied RRs is returned.
|
||||||
func filterRRSlice(rrs []dns.RR, ttl uint32, dup bool) []dns.RR {
|
func filterRRSlice(rrs []dns.RR, ttl uint32, dup bool) []dns.RR {
|
||||||
j := 0
|
j := 0
|
||||||
rs := make([]dns.RR, len(rrs))
|
rs := make([]dns.RR, len(rrs))
|
||||||
@@ -12,12 +12,12 @@ func filterRRSlice(rrs []dns.RR, ttl uint32, dup bool) []dns.RR {
|
|||||||
if r.Header().Rrtype == dns.TypeOPT {
|
if r.Header().Rrtype == dns.TypeOPT {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
r.Header().Ttl = ttl
|
|
||||||
if dup {
|
if dup {
|
||||||
rs[j] = dns.Copy(r)
|
rs[j] = dns.Copy(r)
|
||||||
} else {
|
} else {
|
||||||
rs[j] = r
|
rs[j] = r
|
||||||
}
|
}
|
||||||
|
rs[j].Header().Ttl = ttl
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
return rs[:j]
|
return rs[:j]
|
||||||
|
|||||||
Reference in New Issue
Block a user