File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
library/std/src/sys/net/connection/socket Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -486,18 +486,17 @@ impl Socket {
486
486
// bionic libc makes no use of this flag
487
487
#[ cfg( target_os = "linux" ) ]
488
488
pub fn set_deferaccept ( & self , accept : Duration ) -> io:: Result < ( ) > {
489
- setsockopt (
490
- self ,
491
- libc:: IPPROTO_TCP ,
492
- libc:: TCP_DEFER_ACCEPT ,
493
- accept. as_secs_f64 ( ) . round ( ) as c_int ,
494
- )
489
+ let val = accept. as_secs ( ) ;
490
+ if val > i32:: MAX as _ {
491
+ return Err ( io:: Error :: from_raw_os_error ( libc:: EINVAL ) ) ;
492
+ }
493
+ setsockopt ( self , libc:: IPPROTO_TCP , libc:: TCP_DEFER_ACCEPT , val as c_int )
495
494
}
496
495
497
496
#[ cfg( target_os = "linux" ) ]
498
497
pub fn deferaccept ( & self ) -> io:: Result < Duration > {
499
498
let raw: c_int = getsockopt ( self , libc:: IPPROTO_TCP , libc:: TCP_DEFER_ACCEPT ) ?;
500
- Ok ( Duration :: from_secs ( raw. try_into ( ) . unwrap ( ) ) )
499
+ Ok ( Duration :: from_secs ( raw as _ ) )
501
500
}
502
501
503
502
#[ cfg( any( target_os = "freebsd" , target_os = "netbsd" ) ) ]
You can’t perform that action at this time.
0 commit comments