net: fix data race in benchmarks

Fixes #10307.

Change-Id: If70f36a6f1c4e465a47a0bc4d38b318424111106
Reviewed-on: https://go-review.googlesource.com/8330
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Mikio Hara 2015-04-01 12:21:15 +09:00
parent 9b696be08b
commit 93553dd216
6 changed files with 24 additions and 32 deletions

View file

@ -219,8 +219,7 @@ func TestReloadResolvConfChange(t *testing.T) {
}
func BenchmarkGoLookupIP(b *testing.B) {
uninstallTestHooks()
defer installTestHooks()
testHookUninstaller.Do(func() { uninstallTestHooks() })
for i := 0; i < b.N; i++ {
goLookupIP("www.example.com")
@ -228,8 +227,7 @@ func BenchmarkGoLookupIP(b *testing.B) {
}
func BenchmarkGoLookupIPNoSuchHost(b *testing.B) {
uninstallTestHooks()
defer installTestHooks()
testHookUninstaller.Do(func() { uninstallTestHooks() })
for i := 0; i < b.N; i++ {
goLookupIP("some.nonexistent")
@ -237,8 +235,7 @@ func BenchmarkGoLookupIPNoSuchHost(b *testing.B) {
}
func BenchmarkGoLookupIPWithBrokenNameServer(b *testing.B) {
uninstallTestHooks()
defer installTestHooks()
testHookUninstaller.Do(func() { uninstallTestHooks() })
onceLoadConfig.Do(loadDefaultConfig)
if cfg.dnserr != nil || cfg.dnsConfig == nil {