Skip to content

Commit e63122f

Browse files
committed
Tweak
1 parent 5c896da commit e63122f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

async-ssh2-lite/tests/integration_tests/session__channel_forward_listen.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff 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:{}",

0 commit comments

Comments
 (0)