aboutsummaryrefslogtreecommitdiff
path: root/src/net/dnsclient_unix.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-12-07 20:30:28 -0800
committerIan Lance Taylor <iant@golang.org>2017-12-08 05:12:13 +0000
commit6c877e5da7ab14f0d8a206c09f24cf51fbbc393a (patch)
tree2d4ed0c24d5e0b343a885835c9c0f0e75bbb9d1e /src/net/dnsclient_unix.go
parent6af8c0d812f7bd20d81df986c3ed425f3251e8dc (diff)
downloadgo-6c877e5da7ab14f0d8a206c09f24cf51fbbc393a.tar.gz
go-6c877e5da7ab14f0d8a206c09f24cf51fbbc393a.zip
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>
Diffstat (limited to 'src/net/dnsclient_unix.go')
-rw-r--r--src/net/dnsclient_unix.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go
index acbf6c3b2a..9026fd8c74 100644
--- a/src/net/dnsclient_unix.go
+++ b/src/net/dnsclient_unix.go
@@ -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)