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:
Yong Tang
2026-09-29 01:19:07 -07:00
committed by GitHub
parent 0e9d7f4d05
commit 594d6c9121
2 changed files with 31 additions and 2 deletions

View File

@@ -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)
}