diff options
author | Eugene Kalinin <e.v.kalinin@gmail.com> | 2018-06-21 01:23:37 +0300 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-10-25 03:14:03 +0000 |
commit | c659be4dc862cdf14a24134f2cfc16fa81e6d84c (patch) | |
tree | fb0200ce7fa6e9b5f3ad066e0da1589538ca2c57 /src/net/cgo_unix_test.go | |
parent | fc4f2e5692ab800a450e07c3d983eda02dfd4711 (diff) | |
download | go-git-c659be4dc862cdf14a24134f2cfc16fa81e6d84c.tar.gz |
net: make cgo resolver work more accurately with network parameter
Unlike the go resolver, the existing cgo resolver exchanges both DNS A
and AAAA RR queries unconditionally and causes unreasonable connection
setup latencies to applications using the cgo resolver.
This change adds new argument (`network`) in all functions through the
series of calls: from Resolver.internetAddrList to cgoLookupIPCNAME.
Benefit: no redundant DNS calls if certain IP version is used IPv4/IPv6
(no `AAAA` DNS requests if used tcp4, udp4, ip4 network. And vice
versa: no `A` DNS requests if used tcp6, udp6, ip6 network)
Fixes #25947
Change-Id: I39edbd726d82d6133fdada4d06cd90d401e7e669
Reviewed-on: https://go-review.googlesource.com/c/120215
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/cgo_unix_test.go')
-rw-r--r-- | src/net/cgo_unix_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/net/cgo_unix_test.go b/src/net/cgo_unix_test.go index b476a6d626..c3eab5b3b2 100644 --- a/src/net/cgo_unix_test.go +++ b/src/net/cgo_unix_test.go @@ -15,7 +15,7 @@ import ( func TestCgoLookupIP(t *testing.T) { defer dnsWaitGroup.Wait() ctx := context.Background() - _, err, ok := cgoLookupIP(ctx, "localhost") + _, err, ok := cgoLookupIP(ctx, "ip", "localhost") if !ok { t.Errorf("cgoLookupIP must not be a placeholder") } @@ -28,7 +28,7 @@ func TestCgoLookupIPWithCancel(t *testing.T) { defer dnsWaitGroup.Wait() ctx, cancel := context.WithCancel(context.Background()) defer cancel() - _, err, ok := cgoLookupIP(ctx, "localhost") + _, err, ok := cgoLookupIP(ctx, "ip", "localhost") if !ok { t.Errorf("cgoLookupIP must not be a placeholder") } |