aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-07-03 07:01:57 +0100
committerGravatar GitHub <noreply@github.com> 2019-07-03 07:01:57 +0100
commit3e5fd21e686718ffbbe4d494f9952ba9dca53db7 (patch)
tree4a2292e36d488f690fa0173d4f09009f25f4fb6e /plugin
parentf8bba51f844a9ba9add993dcd579288d3af3707e (diff)
downloadcoredns-3e5fd21e686718ffbbe4d494f9952ba9dca53db7.tar.gz
coredns-3e5fd21e686718ffbbe4d494f9952ba9dca53db7.tar.zst
coredns-3e5fd21e686718ffbbe4d494f9952ba9dca53db7.zip
file: close correctlty after AXFR (#2943)
* file: close correctlty after AXFR Don't hijack, but wait for the writes to be done and then savely close the connection. Fixes: #2929 Signed-off-by: Miek Gieben <miek@miek.nl> * Update comment Signed-off-by: Miek Gieben <miek@miek.nl> * file: close correctlty after AXFR (#2943) apply Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin')
-rw-r--r--plugin/file/xfr.go13
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
}