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 {
486486 // bionic libc makes no use of this flag
487487 #[ cfg( target_os = "linux" ) ]
488488 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 )
495494 }
496495
497496 #[ cfg( target_os = "linux" ) ]
498497 pub fn deferaccept ( & self ) -> io:: Result < Duration > {
499498 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 _ ) )
501500 }
502501
503502 #[ cfg( any( target_os = "freebsd" , target_os = "netbsd" ) ) ]
You can’t perform that action at this time.
0 commit comments