]> Cypherpunks repositories - gostls13.git/commitdiff
net: slowDialTCP should wait forever if no deadline exists.
authorPaul Marks <pmarks@google.com>
Wed, 9 Mar 2016 22:49:39 +0000 (14:49 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 10 Mar 2016 15:24:44 +0000 (15:24 +0000)
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 <pmarks@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
src/net/dial_test.go

index 0bcdbfc925ce1241a864684958ce653726d9307b..5fe3e856f89f0d877c985e29589147f9ba1c901a 100644 (file)
@@ -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