Skip to content

Commit

Permalink
fixed tryagain handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Feb 12, 2025
1 parent 8291bd3 commit a00212c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src-tauri/src/shell_manager/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ impl Shell {
}
}
}
let size = channel.read_timeout(&mut buf, false, Some(Duration::from_micros(5)))?;
let size = match channel.read_timeout(&mut buf, false, Some(Duration::from_micros(5))) {
Ok(size) => size,
Err(libssh_rs::Error::TryAgain) => 0,
Err(e) => return Err(Error::from(e)),
};
if size != 0 {
if let Some(callback) = self.callback.lock().unwrap().as_ref() {
callback.rx(0, &buf[..size]);
Expand All @@ -190,7 +194,12 @@ impl Shell {
}
}
if !has_pty {
let size = channel.read_timeout(&mut buf, true, Some(Duration::from_micros(5)))?;
let size =
match channel.read_timeout(&mut buf, true, Some(Duration::from_micros(5))) {
Ok(size) => size,
Err(libssh_rs::Error::TryAgain) => 0,
Err(e) => return Err(Error::from(e)),
};
if size != 0 {
if let Some(callback) = self.callback.lock().unwrap().as_ref() {
callback.rx(1, &buf[..size]);
Expand Down

0 comments on commit a00212c

Please sign in to comment.