Commit a657e1f6 authored by JINMEI Tatuya's avatar JINMEI Tatuya Committed by Miek Gieben

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.
parent d3e2ef73
...@@ -33,7 +33,10 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in ...@@ -33,7 +33,10 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
ch := make(chan *dns.Envelope) ch := make(chan *dns.Envelope)
defer close(ch) defer close(ch)
tr := new(dns.Transfer) tr := new(dns.Transfer)
go tr.Out(w, r, ch) go func() {
tr.Out(w, r, ch)
w.Close()
}()
j, l := 0, 0 j, l := 0, 0
records = append(records, records[0]) // add closing SOA to the end 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 ...@@ -51,7 +54,6 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
} }
w.Hijack() w.Hijack()
// w.Close() // Client closes connection
return dns.RcodeSuccess, nil return dns.RcodeSuccess, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment