Commit 7eb45d3c authored by Mikio Hara's avatar Mikio Hara

net: don't return a nested error when happy eyeballs dialing

Also removes an unused variable.

Fixes #6795.

R=adg, dave, bradfitz, gobot
CC=golang-dev
https://golang.org/cl/29440043
parent b682f6de
...@@ -172,7 +172,6 @@ func (d *Dialer) Dial(network, address string) (Conn, error) { ...@@ -172,7 +172,6 @@ func (d *Dialer) Dial(network, address string) (Conn, error) {
func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Conn, error) { func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Conn, error) {
type racer struct { type racer struct {
Conn Conn
Addr
error error
} }
// Sig controls the flow of dial results on lane. It passes a // Sig controls the flow of dial results on lane. It passes a
...@@ -184,7 +183,7 @@ func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Con ...@@ -184,7 +183,7 @@ func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Con
go func(ra Addr) { go func(ra Addr) {
c, err := dialSingle(net, addr, la, ra, deadline) c, err := dialSingle(net, addr, la, ra, deadline)
if _, ok := <-sig; ok { if _, ok := <-sig; ok {
lane <- racer{c, ra, err} lane <- racer{c, err}
} else if err == nil { } else if err == nil {
// We have to return the resources // We have to return the resources
// that belong to the other // that belong to the other
...@@ -195,7 +194,6 @@ func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Con ...@@ -195,7 +194,6 @@ func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Con
}(ra.toAddr()) }(ra.toAddr())
} }
defer close(sig) defer close(sig)
var failAddr Addr
lastErr := errTimeout lastErr := errTimeout
nracers := len(ras) nracers := len(ras)
for nracers > 0 { for nracers > 0 {
...@@ -205,12 +203,11 @@ func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Con ...@@ -205,12 +203,11 @@ func dialMulti(net, addr string, la Addr, ras addrList, deadline time.Time) (Con
if racer.error == nil { if racer.error == nil {
return racer.Conn, nil return racer.Conn, nil
} }
failAddr = racer.Addr
lastErr = racer.error lastErr = racer.error
nracers-- nracers--
} }
} }
return nil, &OpError{Op: "dial", Net: net, Addr: failAddr, Err: lastErr} return nil, lastErr
} }
// dialSingle attempts to establish and returns a single connection to // dialSingle attempts to establish and returns a single connection to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment