@@ -63,10 +63,8 @@ macro_rules! impl_nio_read {
6363 $crate:: syscall:: common:: set_non_blocking( $fd) ;
6464 }
6565 let start_time = $crate:: common:: now( ) ;
66- let mut left_time = start_time
67- . saturating_add( $crate:: syscall:: common:: recv_time_limit( $fd) )
68- . saturating_sub( start_time) ;
69- let mut r = -1 ;
66+ let mut left_time = $crate:: syscall:: common:: recv_time_limit( $fd) ;
67+ let mut r = 0 ;
7068 while left_time > 0 {
7169 r = self . inner. $syscall( fn_ptr, $fd, $( $arg, ) * ) ;
7270 if r != -1 as _ {
@@ -123,9 +121,7 @@ macro_rules! impl_nio_read_buf {
123121 $crate:: syscall:: common:: set_non_blocking( $fd) ;
124122 }
125123 let start_time = $crate:: common:: now( ) ;
126- let mut left_time = start_time
127- . saturating_add( $crate:: syscall:: common:: recv_time_limit( $fd) )
128- . saturating_sub( start_time) ;
124+ let mut left_time = $crate:: syscall:: common:: recv_time_limit( $fd) ;
129125 let mut received = 0 ;
130126 let mut r = 0 ;
131127 while received < $len && left_time > 0 {
@@ -196,9 +192,7 @@ macro_rules! impl_nio_read_iovec {
196192 $crate:: syscall:: common:: set_non_blocking( $fd) ;
197193 }
198194 let start_time = $crate:: common:: now( ) ;
199- let mut left_time = start_time
200- . saturating_add( $crate:: syscall:: common:: recv_time_limit( $fd) )
201- . saturating_sub( start_time) ;
195+ let mut left_time = $crate:: syscall:: common:: recv_time_limit( $fd) ;
202196 let vec = unsafe { Vec :: from_raw_parts( $iov. cast_mut( ) , $iovcnt as usize , $iovcnt as usize ) } ;
203197 let mut length = 0 ;
204198 let mut received = 0usize ;
@@ -309,9 +303,7 @@ macro_rules! impl_nio_write_buf {
309303 $crate:: syscall:: common:: set_non_blocking( $fd) ;
310304 }
311305 let start_time = $crate:: common:: now( ) ;
312- let mut left_time = start_time
313- . saturating_add( $crate:: syscall:: common:: send_time_limit( $fd) )
314- . saturating_sub( start_time) ;
306+ let mut left_time = $crate:: syscall:: common:: send_time_limit( $fd) ;
315307 let mut sent = 0 ;
316308 let mut r = 0 ;
317309 while sent < $len && left_time > 0 {
@@ -382,9 +374,7 @@ macro_rules! impl_nio_write_iovec {
382374 $crate:: syscall:: common:: set_non_blocking( $fd) ;
383375 }
384376 let start_time = $crate:: common:: now( ) ;
385- let mut left_time = start_time
386- . saturating_add( $crate:: syscall:: common:: send_time_limit( $fd) )
387- . saturating_sub( start_time) ;
377+ let mut left_time = $crate:: syscall:: common:: send_time_limit( $fd) ;
388378 let vec = unsafe { Vec :: from_raw_parts( $iov. cast_mut( ) , $iovcnt as usize , $iovcnt as usize ) } ;
389379 let mut length = 0 ;
390380 let mut sent = 0usize ;
@@ -401,7 +391,7 @@ macro_rules! impl_nio_write_iovec {
401391 for i in vec. iter( ) . skip( index) {
402392 arg. push( * i) ;
403393 }
404- while sent < length {
394+ while sent < length && left_time > 0 {
405395 if 0 != offset {
406396 arg[ 0 ] = windows_sys:: Win32 :: Networking :: WinSock :: WSABUF {
407397 buf: ( arg[ 0 ] . buf as usize + offset) as windows_sys:: core:: PSTR ,
@@ -577,7 +567,7 @@ pub extern "system" fn send_time_limit(fd: SOCKET) -> u64 {
577567 // not a socket
578568 return u64:: MAX ;
579569 }
580- panic ! ( "getsockopt failed: {}" , error ) ;
570+ panic ! ( "getsockopt failed: {error}" ) ;
581571 }
582572 let mut time_limit = ( ms as u64 ) . saturating_mul ( 1_000_000 ) ;
583573 if 0 == time_limit {
@@ -612,7 +602,7 @@ pub extern "system" fn recv_time_limit(fd: SOCKET) -> u64 {
612602 // not a socket
613603 return u64:: MAX ;
614604 }
615- panic ! ( "getsockopt failed: {}" , error ) ;
605+ panic ! ( "getsockopt failed: {error}" ) ;
616606 }
617607 let mut time_limit = ( ms as u64 ) . saturating_mul ( 1_000_000 ) ;
618608 if 0 == time_limit {
0 commit comments