Commit 3ad3d593 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net: fix race in test

Fixes race builders, broken in https://golang.org/cl/16953

Change-Id: Id61171672b69d0ca412de4b44bf2c598fe557906
Reviewed-on: https://go-review.googlesource.com/17936
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 0d641c75
......@@ -515,7 +515,8 @@ func BenchmarkGoLookupIPWithBrokenNameServer(b *testing.B) {
type fakeDNSConn struct {
// last query
q *dnsMsg
qmu sync.Mutex // guards q
q *dnsMsg
// reply handler
rh func(*dnsMsg) (*dnsMsg, error)
}
......@@ -533,10 +534,15 @@ func (f *fakeDNSConn) SetDeadline(time.Time) error {
}
func (f *fakeDNSConn) writeDNSQuery(q *dnsMsg) error {
f.qmu.Lock()
defer f.qmu.Unlock()
f.q = q
return nil
}
func (f *fakeDNSConn) readDNSResponse() (*dnsMsg, error) {
return f.rh(f.q)
f.qmu.Lock()
q := f.q
f.qmu.Unlock()
return f.rh(q)
}
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