diff options
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/file/xfr.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plugin/file/xfr.go b/plugin/file/xfr.go index 18b6bb117..08f71030a 100644 --- a/plugin/file/xfr.go +++ b/plugin/file/xfr.go @@ -3,6 +3,7 @@ package file import ( "context" "fmt" + "sync" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/request" @@ -31,9 +32,13 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in } ch := make(chan *dns.Envelope) - defer close(ch) tr := new(dns.Transfer) - go tr.Out(w, r, ch) + wg := new(sync.WaitGroup) + go func() { + wg.Add(1) + tr.Out(w, r, ch) + wg.Done() + }() j, l := 0, 0 records = append(records, records[0]) // add closing SOA to the end @@ -49,9 +54,9 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in if j < len(records) { ch <- &dns.Envelope{RR: records[j:]} } + close(ch) // Even though we close the channel here, we still have + wg.Wait() // to wait before we can return and close the connection. - w.Hijack() - // w.Close() // Client closes connection return dns.RcodeSuccess, nil } |