diff options
author | 2019-06-04 23:21:59 -0700 | |
---|---|---|
committer | 2019-06-05 07:21:59 +0100 | |
commit | a657e1f6618ee94c46fa9374dd29c21345710d38 (patch) | |
tree | e2ec396e0b0c65e03abd8057fc673dc51ee5baf0 | |
parent | d3e2ef73b8f5f2f3c0ef4383353d1aedd88cf3b9 (diff) | |
download | coredns-a657e1f6618ee94c46fa9374dd29c21345710d38.tar.gz coredns-a657e1f6618ee94c46fa9374dd29c21345710d38.tar.zst coredns-a657e1f6618ee94c46fa9374dd29c21345710d38.zip |
be sure to close connection after completion of xfr out. (#2866)
otherwise the connection and associated socket stay in the CLOSE_WAIT
state unless/until golang runtime performs GC.
-rw-r--r-- | plugin/file/xfr.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugin/file/xfr.go b/plugin/file/xfr.go index 18b6bb117..6be265b34 100644 --- a/plugin/file/xfr.go +++ b/plugin/file/xfr.go @@ -33,7 +33,10 @@ 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) + go func() { + tr.Out(w, r, ch) + w.Close() + }() j, l := 0, 0 records = append(records, records[0]) // add closing SOA to the end @@ -51,7 +54,6 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in } w.Hijack() - // w.Close() // Client closes connection return dns.RcodeSuccess, nil } |