Skip to content

Commit a00212c

Browse files
committed
fixed tryagain handling
1 parent 8291bd3 commit a00212c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src-tauri/src/shell_manager/shell.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ impl Shell {
178178
}
179179
}
180180
}
181-
let size = channel.read_timeout(&mut buf, false, Some(Duration::from_micros(5)))?;
181+
let size = match channel.read_timeout(&mut buf, false, Some(Duration::from_micros(5))) {
182+
Ok(size) => size,
183+
Err(libssh_rs::Error::TryAgain) => 0,
184+
Err(e) => return Err(Error::from(e)),
185+
};
182186
if size != 0 {
183187
if let Some(callback) = self.callback.lock().unwrap().as_ref() {
184188
callback.rx(0, &buf[..size]);
@@ -190,7 +194,12 @@ impl Shell {
190194
}
191195
}
192196
if !has_pty {
193-
let size = channel.read_timeout(&mut buf, true, Some(Duration::from_micros(5)))?;
197+
let size =
198+
match channel.read_timeout(&mut buf, true, Some(Duration::from_micros(5))) {
199+
Ok(size) => size,
200+
Err(libssh_rs::Error::TryAgain) => 0,
201+
Err(e) => return Err(Error::from(e)),
202+
};
194203
if size != 0 {
195204
if let Some(callback) = self.callback.lock().unwrap().as_ref() {
196205
callback.rx(1, &buf[..size]);

0 commit comments

Comments
 (0)