plugin/file: introduce snapshot()/setData() accessors for zone data (#8040)

Signed-off-by: Ryan Brewster <rpb@anthropic.com>
This commit is contained in:
rpb-ant
2026-04-12 13:34:36 -04:00
committed by GitHub
parent 8a28dc9c7d
commit 50cbaf87a0
5 changed files with 41 additions and 52 deletions

View File

@@ -19,20 +19,16 @@ func (f File) Transfer(zone string, serial uint32) (<-chan []dns.RR, error) {
// Transfer transfers a zone with serial in the returned channel and implements IXFR fallback, by just
// sending a single SOA record.
func (z *Zone) Transfer(serial uint32) (<-chan []dns.RR, error) {
// Snapshot apex and tree under one read lock so the goroutine walks the
// same generation the SOA came from, even if TransferIn swaps them mid-AXFR.
z.RLock()
apex, err := z.apexIfDefinedLocked()
t := z.Tree
z.RUnlock()
ap, t := z.snapshot()
apex, err := ap.records()
if err != nil {
return nil, err
}
ch := make(chan []dns.RR)
go func() {
if serial != 0 && apex[0].(*dns.SOA).Serial == serial { // ixfr fallback, only send SOA
ch <- []dns.RR{apex[0]}
if serial != 0 && ap.SOA.Serial == serial { // ixfr fallback, only send SOA
ch <- []dns.RR{ap.SOA}
close(ch)
return
@@ -40,7 +36,7 @@ func (z *Zone) Transfer(serial uint32) (<-chan []dns.RR, error) {
ch <- apex
t.Walk(func(e *tree.Elem, _ map[uint16][]dns.RR) error { ch <- e.All(); return nil })
ch <- []dns.RR{apex[0]}
ch <- []dns.RR{ap.SOA}
close(ch)
}()