File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
async-ssh2-lite/tests/integration_tests Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -90,8 +90,13 @@ async fn __run__session__channel_forward_listen__with_tokio_spawn<
9090 tokio:: task:: spawn ( async move {
9191 let mut buf = vec ! [ 0 ; 128 ] ;
9292 let mut n_read = 0 ;
93+ let mut n_retry = 0 ;
9394 loop {
94- let n = channel. read ( & mut buf[ n_read..] ) . await ?;
95+ let n = tokio:: time:: timeout (
96+ tokio:: time:: Duration :: from_millis ( 3000 ) ,
97+ channel. read ( & mut buf[ n_read..] ) ,
98+ )
99+ . await ??;
95100 n_read += n;
96101 if n == 0 {
97102 break ;
@@ -100,6 +105,11 @@ async fn __run__session__channel_forward_listen__with_tokio_spawn<
100105 if n_read >= 78 {
101106 break ;
102107 }
108+ n_retry += 1 ;
109+ if n_retry > 3 {
110+ eprintln ! ( "Max read attempts reached." ) ;
111+ break ;
112+ }
103113 }
104114 println ! (
105115 "channel.read successful, data:{}" ,
You can’t perform that action at this time.
0 commit comments