mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: avoid race on test hooks with DNS goroutines
The DNS code can start goroutines and not wait for them to complete. This does no harm, but in tests this can cause a race condition with the test hooks that are installed and unintalled around the tests. Add a WaitGroup that tests of DNS can use to avoid the race. Fixes #21090 Change-Id: I6c1443a9c2378e8b89d0ab1d6390c0e3e726b0ce Reviewed-on: https://go-review.googlesource.com/82795 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
6af8c0d812
commit
6c877e5da7
7 changed files with 95 additions and 5 deletions
|
|
@ -479,7 +479,9 @@ func (r *Resolver) goLookupIPCNAMEOrder(ctx context.Context, name string, order
|
|||
var lastErr error
|
||||
for _, fqdn := range conf.nameList(name) {
|
||||
for _, qtype := range qtypes {
|
||||
dnsWaitGroup.Add(1)
|
||||
go func(qtype uint16) {
|
||||
defer dnsWaitGroup.Done()
|
||||
cname, rrs, err := r.tryOneName(ctx, conf, fqdn, qtype)
|
||||
lane <- racer{cname, rrs, err}
|
||||
}(qtype)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue