mirror of
https://github.com/golang/go
synced 2024-11-17 23:04:56 -07:00
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: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
0d641c754f
commit
3ad3d5931b
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user