Improve: url-test retry dial when failed (#283)

This commit is contained in:
gVisor bot 2019-08-28 22:28:02 +08:00
parent 72ff58216d
commit db11be9306

View file

@ -33,14 +33,16 @@ func (u *URLTest) Now() string {
return u.fast.Name() return u.fast.Name()
} }
func (u *URLTest) Dial(metadata *C.Metadata) (C.Conn, error) { func (u *URLTest) Dial(metadata *C.Metadata) (c C.Conn, err error) {
a, err := u.fast.Dial(metadata) for i := 0; i < 3; i++ {
if err != nil { c, err = u.fast.Dial(metadata)
if err == nil {
c.AppendToChains(u)
return
}
u.fallback() u.fallback()
} else {
a.AppendToChains(u)
} }
return a, err return
} }
func (u *URLTest) DialUDP(metadata *C.Metadata) (C.PacketConn, net.Addr, error) { func (u *URLTest) DialUDP(metadata *C.Metadata) (C.PacketConn, net.Addr, error) {