]> Cypherpunks repositories - gostls13.git/commit
net: add sequential and RFC 6555-compliant TCP dialing.
authorPaul Marks <pmarks@google.com>
Fri, 10 Apr 2015 21:15:54 +0000 (14:15 -0700)
committerPaul Marks <pmarks@google.com>
Tue, 16 Jun 2015 02:38:21 +0000 (02:38 +0000)
commit0d8366e2d66bb56fcda7669837dfeb289e9131e3
tree93b887129ae6c3d90e47d0eb8cf476230c41f7fb
parent12b05bf8fd63634589f71d6ba9d8519d0ae8184b
net: add sequential and RFC 6555-compliant TCP dialing.

dialSerial connects to a list of addresses in sequence.  If a
timeout is specified, then each address gets an equal fraction of the
remaining time, with a magic constant (2 seconds) to prevent
"dial a million addresses" from allotting zero time to each.

Normally, net.Dial passes the DNS stub resolver's output to dialSerial.
If an error occurs (like destination/port unreachable), it quickly skips
to the next address, but a blackhole in the network will cause the
connection to hang until the timeout elapses.  This is how UNIXy clients
traditionally behave, and is usually sufficient for non-broken networks.

The DualStack flag enables dialParallel, which implements Happy Eyeballs
by racing two dialSerial goroutines, giving the preferred family a
head start (300ms by default).  This allows clients to avoid long
timeouts when the network blackholes IPv4 xor IPv6.

Fixes #8453
Fixes #8455
Fixes #8847

Change-Id: Ie415809c9226a1f7342b0217dcdd8f224ae19058
Reviewed-on: https://go-review.googlesource.com/8768
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/dial.go
src/net/dial_test.go
src/net/hook.go
src/net/net.go