We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d641c7 commit 3ad3d59Copy full SHA for 3ad3d59
src/net/dnsclient_unix_test.go
@@ -515,7 +515,8 @@ func BenchmarkGoLookupIPWithBrokenNameServer(b *testing.B) {
515
516
type fakeDNSConn struct {
517
// last query
518
- q *dnsMsg
+ qmu sync.Mutex // guards q
519
+ q *dnsMsg
520
// reply handler
521
rh func(*dnsMsg) (*dnsMsg, error)
522
}
@@ -533,10 +534,15 @@ func (f *fakeDNSConn) SetDeadline(time.Time) error {
533
534
535
536
func (f *fakeDNSConn) writeDNSQuery(q *dnsMsg) error {
537
+ f.qmu.Lock()
538
+ defer f.qmu.Unlock()
539
f.q = q
540
return nil
541
542
543
func (f *fakeDNSConn) readDNSResponse() (*dnsMsg, error) {
- return f.rh(f.q)
544
545
+ q := f.q
546
+ f.qmu.Unlock()
547
+ return f.rh(q)
548
0 commit comments