Call wg.Add in main goroutine to avoid race conditons. (#3433)

Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
This commit is contained in:
Guangming Wang
2019-11-07 23:29:50 +08:00
committed by Miek Gieben
parent 1942746c48
commit 113783ed91

View File

@@ -109,8 +109,8 @@ func (t Transfer) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
ch := make(chan *dns.Envelope)
tr := new(dns.Transfer)
wg := new(sync.WaitGroup)
wg.Add(1)
go func() {
wg.Add(1)
tr.Out(w, r, ch)
wg.Done()
}()