File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ impl TcpStream {
130
130
pub fn set_read_timeout ( & self , duration_option : Option < Duration > ) -> Result < ( ) > {
131
131
let file = self . 0 . dup ( b"read_timeout" ) ?;
132
132
if let Some ( duration) = duration_option {
133
+ if dur. as_secs ( ) == 0 && dur. subsec_nanos ( ) == 0 {
134
+ return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
135
+ "cannot set a 0 duration timeout" ) ) ;
136
+ }
133
137
file. write ( & TimeSpec {
134
138
tv_sec : duration. as_secs ( ) as i64 ,
135
139
tv_nsec : duration. subsec_nanos ( ) as i32
@@ -143,6 +147,10 @@ impl TcpStream {
143
147
pub fn set_write_timeout ( & self , duration_option : Option < Duration > ) -> Result < ( ) > {
144
148
let file = self . 0 . dup ( b"write_timeout" ) ?;
145
149
if let Some ( duration) = duration_option {
150
+ if dur. as_secs ( ) == 0 && dur. subsec_nanos ( ) == 0 {
151
+ return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
152
+ "cannot set a 0 duration timeout" ) ) ;
153
+ }
146
154
file. write ( & TimeSpec {
147
155
tv_sec : duration. as_secs ( ) as i64 ,
148
156
tv_nsec : duration. subsec_nanos ( ) as i32
Original file line number Diff line number Diff line change @@ -179,6 +179,10 @@ impl UdpSocket {
179
179
pub fn set_read_timeout ( & self , duration_option : Option < Duration > ) -> Result < ( ) > {
180
180
let file = self . 0 . dup ( b"read_timeout" ) ?;
181
181
if let Some ( duration) = duration_option {
182
+ if dur. as_secs ( ) == 0 && dur. subsec_nanos ( ) == 0 {
183
+ return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
184
+ "cannot set a 0 duration timeout" ) ) ;
185
+ }
182
186
file. write ( & TimeSpec {
183
187
tv_sec : duration. as_secs ( ) as i64 ,
184
188
tv_nsec : duration. subsec_nanos ( ) as i32
@@ -192,6 +196,10 @@ impl UdpSocket {
192
196
pub fn set_write_timeout ( & self , duration_option : Option < Duration > ) -> Result < ( ) > {
193
197
let file = self . 0 . dup ( b"write_timeout" ) ?;
194
198
if let Some ( duration) = duration_option {
199
+ if dur. as_secs ( ) == 0 && dur. subsec_nanos ( ) == 0 {
200
+ return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
201
+ "cannot set a 0 duration timeout" ) ) ;
202
+ }
195
203
file. write ( & TimeSpec {
196
204
tv_sec : duration. as_secs ( ) as i64 ,
197
205
tv_nsec : duration. subsec_nanos ( ) as i32
You can’t perform that action at this time.
0 commit comments