From 518354e7ebd3362315f02f34a6a9ce21131f8fc9 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Tue, 24 Mar 2020 10:13:53 +0800 Subject: [PATCH] Fix: dns request panic and close #527 --- dns/resolver.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dns/resolver.go b/dns/resolver.go index dc526a7b..f1f51a98 100644 --- a/dns/resolver.go +++ b/dns/resolver.go @@ -115,7 +115,7 @@ func (r *Resolver) Exchange(m *D.Msg) (msg *D.Msg, err error) { } }() - ret, err, _ := r.group.Do(q.String(), func() (interface{}, error) { + ret, err, shared := r.group.Do(q.String(), func() (interface{}, error) { isIPReq := isIPRequest(q) if isIPReq { return r.fallbackExchange(m) @@ -126,6 +126,9 @@ func (r *Resolver) Exchange(m *D.Msg) (msg *D.Msg, err error) { if err == nil { msg = ret.(*D.Msg) + if shared { + msg = msg.Copy() + } } return