@@ -3667,12 +3667,12 @@ func TestIdleConnH2Crash(t *testing.T) {
3667
3667
ctx , cancel := context .WithCancel (context .Background ())
3668
3668
defer cancel ()
3669
3669
3670
- gotErr := make (chan bool , 1 )
3670
+ sawDoErr := make (chan bool , 1 )
3671
+ testDone := make (chan struct {})
3672
+ defer close (testDone )
3671
3673
3672
3674
cst .tr .IdleConnTimeout = 5 * time .Millisecond
3673
3675
cst .tr .DialTLS = func (network , addr string ) (net.Conn , error ) {
3674
- cancel ()
3675
- <- gotErr
3676
3676
c , err := tls .Dial (network , addr , & tls.Config {
3677
3677
InsecureSkipVerify : true ,
3678
3678
NextProtos : []string {"h2" },
@@ -3686,6 +3686,17 @@ func TestIdleConnH2Crash(t *testing.T) {
3686
3686
c .Close ()
3687
3687
return nil , errors .New ("bogus" )
3688
3688
}
3689
+
3690
+ cancel ()
3691
+
3692
+ failTimer := time .NewTimer (5 * time .Second )
3693
+ defer failTimer .Stop ()
3694
+ select {
3695
+ case <- sawDoErr :
3696
+ case <- testDone :
3697
+ case <- failTimer .C :
3698
+ t .Error ("timeout in DialTLS, waiting too long for cst.c.Do to fail" )
3699
+ }
3689
3700
return c , nil
3690
3701
}
3691
3702
@@ -3696,7 +3707,7 @@ func TestIdleConnH2Crash(t *testing.T) {
3696
3707
res .Body .Close ()
3697
3708
t .Fatal ("unexpected success" )
3698
3709
}
3699
- gotErr <- true
3710
+ sawDoErr <- true
3700
3711
3701
3712
// Wait for the explosion.
3702
3713
time .Sleep (cst .tr .IdleConnTimeout * 10 )
0 commit comments