aboutsummaryrefslogtreecommitdiff
path: root/src/net/dial_test.go
diff options
context:
space:
mode:
authorEugene Kalinin <e.v.kalinin@gmail.com>2018-06-21 01:23:37 +0300
committerBrad Fitzpatrick <bradfitz@golang.org>2018-10-25 03:14:03 +0000
commitc659be4dc862cdf14a24134f2cfc16fa81e6d84c (patch)
treefb0200ce7fa6e9b5f3ad066e0da1589538ca2c57 /src/net/dial_test.go
parentfc4f2e5692ab800a450e07c3d983eda02dfd4711 (diff)
downloadgo-c659be4dc862cdf14a24134f2cfc16fa81e6d84c.tar.gz
go-c659be4dc862cdf14a24134f2cfc16fa81e6d84c.zip
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/dial_test.go')
-rw-r--r--src/net/dial_test.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/net/dial_test.go b/src/net/dial_test.go
index 3a45c0d2ec..983338885d 100644
--- a/src/net/dial_test.go
+++ b/src/net/dial_test.go
@@ -346,7 +346,7 @@ func TestDialParallel(t *testing.T) {
}
}
-func lookupSlowFast(ctx context.Context, fn func(context.Context, string) ([]IPAddr, error), host string) ([]IPAddr, error) {
+func lookupSlowFast(ctx context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) {
switch host {
case "slow6loopback4":
// Returns a slow IPv6 address, and a local IPv4 address.
@@ -355,7 +355,7 @@ func lookupSlowFast(ctx context.Context, fn func(context.Context, string) ([]IPA
{IP: ParseIP("127.0.0.1")},
}, nil
default:
- return fn(ctx, host)
+ return fn(ctx, network, host)
}
}