mirror of
https://github.com/coredns/coredns.git
synced 2026-10-17 07:45:42 -04:00
plugin/file: Fix race condition in file plugin closer (#8583)
This PR fixes race condition in file plugin closer Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -8,9 +8,14 @@ import (
|
||||
|
||||
// ClosestEncloser returns the closest encloser for qname.
|
||||
func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) {
|
||||
_, zoneTree := z.snapshot()
|
||||
if zoneTree == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
offset, end := dns.NextLabel(qname, 0)
|
||||
for !end {
|
||||
elem, _ := z.Search(qname)
|
||||
elem, _ := zoneTree.Search(qname)
|
||||
if elem != nil {
|
||||
return elem, true
|
||||
}
|
||||
@@ -19,5 +24,5 @@ func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) {
|
||||
offset, end = dns.NextLabel(qname, 0)
|
||||
}
|
||||
|
||||
return z.Search(z.origin)
|
||||
return zoneTree.Search(z.origin)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user