@@ -24,18 +24,17 @@ var dialTimeoutTests = []struct {
24
24
delta time.Duration // for deadline
25
25
26
26
guard time.Duration
27
- max time.Duration
28
27
}{
29
28
// Tests that dial timeouts, deadlines in the past work.
30
- {- 5 * time .Second , 0 , - 5 * time .Second , 100 * time . Millisecond },
31
- {0 , - 5 * time .Second , - 5 * time .Second , 100 * time . Millisecond },
32
- {- 5 * time .Second , 5 * time .Second , - 5 * time .Second , 100 * time . Millisecond }, // timeout over deadline
33
- {- 1 << 63 , 0 , time .Second , 100 * time . Millisecond },
34
- {0 , - 1 << 63 , time .Second , 100 * time . Millisecond },
35
-
36
- {50 * time .Millisecond , 0 , 100 * time .Millisecond , time . Second },
37
- {0 , 50 * time .Millisecond , 100 * time .Millisecond , time . Second },
38
- {50 * time .Millisecond , 5 * time .Second , 100 * time .Millisecond , time . Second }, // timeout over deadline
29
+ {- 5 * time .Second , 0 , - 5 * time .Second },
30
+ {0 , - 5 * time .Second , - 5 * time .Second },
31
+ {- 5 * time .Second , 5 * time .Second , - 5 * time .Second }, // timeout over deadline
32
+ {- 1 << 63 , 0 , time .Second },
33
+ {0 , - 1 << 63 , time .Second },
34
+
35
+ {50 * time .Millisecond , 0 , 100 * time .Millisecond },
36
+ {0 , 50 * time .Millisecond , 100 * time .Millisecond },
37
+ {50 * time .Millisecond , 5 * time .Second , 100 * time .Millisecond }, // timeout over deadline
39
38
}
40
39
41
40
func TestDialTimeout (t * testing.T ) {
@@ -59,35 +58,25 @@ func TestDialTimeout(t *testing.T) {
59
58
})
60
59
}
61
60
62
- ch := make (chan error )
63
61
d := Dialer {Timeout : tt .timeout }
64
62
if tt .delta != 0 {
65
63
d .Deadline = time .Now ().Add (tt .delta )
66
64
}
67
- max := time .NewTimer (tt .max )
68
- defer max .Stop ()
69
- go func () {
70
- // This dial never starts to send any TCP SYN
71
- // segment because of above socket filter and
72
- // test hook.
73
- c , err := d .Dial ("tcp" , "127.0.0.1:0" )
74
- if err == nil {
75
- err = fmt .Errorf ("unexpectedly established: tcp:%s->%s" , c .LocalAddr (), c .RemoteAddr ())
76
- c .Close ()
77
- }
78
- ch <- err
79
- }()
80
65
81
- select {
82
- case <- max .C :
83
- t .Fatalf ("#%d: Dial didn't return in an expected time" , i )
84
- case err := <- ch :
85
- if perr := parseDialError (err ); perr != nil {
86
- t .Errorf ("#%d: %v" , i , perr )
87
- }
88
- if nerr , ok := err .(Error ); ! ok || ! nerr .Timeout () {
89
- t .Fatalf ("#%d: %v" , i , err )
90
- }
66
+ // This dial never starts to send any TCP SYN
67
+ // segment because of above socket filter and
68
+ // test hook.
69
+ c , err := d .Dial ("tcp" , "127.0.0.1:0" )
70
+ if err == nil {
71
+ err = fmt .Errorf ("unexpectedly established: tcp:%s->%s" , c .LocalAddr (), c .RemoteAddr ())
72
+ c .Close ()
73
+ }
74
+
75
+ if perr := parseDialError (err ); perr != nil {
76
+ t .Errorf ("#%d: %v" , i , perr )
77
+ }
78
+ if nerr , ok := err .(Error ); ! ok || ! nerr .Timeout () {
79
+ t .Fatalf ("#%d: %v" , i , err )
91
80
}
92
81
}
93
82
}
0 commit comments