mirror of
https://github.com/coredns/coredns.git
synced 2026-04-20 02:45:32 -04:00
plugin/file: introduce snapshot()/setData() accessors for zone data (#8040)
Signed-off-by: Ryan Brewster <rpb@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user