@@ -66,16 +66,13 @@ pub(crate) fn connect_verified(
6666 let mut unavailable = None ;
6767 loop {
6868 check_running ( & process) ?;
69- let remaining = deadline
70- . checked_duration_since ( Instant :: now ( ) )
71- . filter ( |remaining| !remaining. is_zero ( ) )
72- . ok_or_else ( || {
73- Error :: timed_out ( "the control connection timed out" ) . with_source (
74- unavailable
75- . take ( )
76- . unwrap_or_else ( || io:: Error :: from ( io:: ErrorKind :: TimedOut ) ) ,
77- )
78- } ) ?;
69+ let remaining = platform:: time_until ( deadline) . ok_or_else ( || {
70+ Error :: timed_out ( "the control connection timed out" ) . with_source (
71+ unavailable
72+ . take ( )
73+ . unwrap_or_else ( || io:: Error :: from ( io:: ErrorKind :: TimedOut ) ) ,
74+ )
75+ } ) ?;
7976 let attempt =
8077 platform:: connect_endpoint ( endpoint, reference. pid , remaining. min ( ATTEMPT_TIMEOUT ) ) ;
8178 check_running ( & process) ?;
@@ -402,14 +399,9 @@ impl HostConnection {
402399
403400/// Converts a deadline into the time left, failing once it has passed.
404401fn remaining ( deadline : Option < Instant > ) -> Result < Option < Duration > , HostConnectionError > {
405- match deadline {
406- None => Ok ( None ) ,
407- Some ( deadline) => deadline
408- . checked_duration_since ( Instant :: now ( ) )
409- . filter ( |remaining| !remaining. is_zero ( ) )
410- . map ( Some )
411- . ok_or ( HostConnectionError :: TimedOut ) ,
412- }
402+ deadline
403+ . map ( |deadline| platform:: time_until ( deadline) . ok_or ( HostConnectionError :: TimedOut ) )
404+ . transpose ( )
413405}
414406
415407/// Returns the failure for an event that the session reports in no state that the connection
0 commit comments