From: Paul Marks Date: Wed, 9 Mar 2016 22:49:39 +0000 (-0800) Subject: net: slowDialTCP should wait forever if no deadline exists. X-Git-Tag: go1.7beta1~1426 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=92dfc12610853d48b7a67912c771cd813371365f;p=gostls13.git net: slowDialTCP should wait forever if no deadline exists. This allows TestDialerFallbackDelay to pass again on machines where IPv6 connections to nowhere fail quickly instead of hanging. This bug appeared last month, when I deleted the slowTimeout constant. Updates #11225 Fixes #14731 Change-Id: I840011eee571aab1041022411541736111c7fad5 Reviewed-on: https://go-review.googlesource.com/20493 Run-TryBot: Paul Marks Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Mikio Hara --- diff --git a/src/net/dial_test.go b/src/net/dial_test.go index 0bcdbfc925..5fe3e856f8 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -238,9 +238,14 @@ const ( func slowDialTCP(net string, laddr, raddr *TCPAddr, deadline time.Time, cancel <-chan struct{}) (*TCPConn, error) { c, err := dialTCP(net, laddr, raddr, deadline, cancel) if ParseIP(slowDst4).Equal(raddr.IP) || ParseIP(slowDst6).Equal(raddr.IP) { + // Wait for the deadline, or indefinitely if none exists. + var wait <-chan time.Time + if !deadline.IsZero() { + wait = time.After(deadline.Sub(time.Now())) + } select { case <-cancel: - case <-time.After(deadline.Sub(time.Now())): + case <-wait: } } return c, err