I was worried over nothing
The two key presses was because of tokio's no-blocking stdin() and it was so that we could be sure to pipe stdin but we don't have to because ssh does its own nonsense.
This commit is contained in:
parent
9eb5565f66
commit
4b2c9811dc
1 changed files with 3 additions and 13 deletions
16
src/lib.rs
16
src/lib.rs
|
|
@ -162,10 +162,7 @@ async fn server_main<Reader: AsyncRead + Unpin, Writer: AsyncWrite + Unpin>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn client_sync<Read: AsyncRead + Unpin, Write: AsyncWrite + Unpin>(
|
async fn client_sync<Read: AsyncRead + Unpin>(reader: &mut Read) -> Result<(), tokio::io::Error> {
|
||||||
reader: &mut Read,
|
|
||||||
writer: &mut Write,
|
|
||||||
) -> Result<(), tokio::io::Error> {
|
|
||||||
// eprintln!("> Waiting for synchronization marker...");
|
// eprintln!("> Waiting for synchronization marker...");
|
||||||
|
|
||||||
// Run these two loops in parallel; the copy of stdin should stop when
|
// Run these two loops in parallel; the copy of stdin should stop when
|
||||||
|
|
@ -173,13 +170,6 @@ async fn client_sync<Read: AsyncRead + Unpin, Write: AsyncWrite + Unpin>(
|
||||||
// reason then obviously we quit.
|
// reason then obviously we quit.
|
||||||
let mut stdout = tokio::io::stdout();
|
let mut stdout = tokio::io::stdout();
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
result = async {
|
|
||||||
let mut stdin = tokio::io::stdin();
|
|
||||||
tokio::io::copy(&mut stdin, writer).await
|
|
||||||
} => match result {
|
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(e) => Err(e),
|
|
||||||
},
|
|
||||||
result = async {
|
result = async {
|
||||||
let mut seen = 0;
|
let mut seen = 0;
|
||||||
while seen < 8 {
|
while seen < 8 {
|
||||||
|
|
@ -428,7 +418,7 @@ pub async fn run_client(remote: &str) {
|
||||||
// TODO: Drive a reconnect loop
|
// TODO: Drive a reconnect loop
|
||||||
let mut child = spawn_ssh(remote).await.expect("failed to spawn");
|
let mut child = spawn_ssh(remote).await.expect("failed to spawn");
|
||||||
|
|
||||||
let mut writer = child
|
let writer = child
|
||||||
.stdin
|
.stdin
|
||||||
.take()
|
.take()
|
||||||
.expect("child did not have a handle to stdin");
|
.expect("child did not have a handle to stdin");
|
||||||
|
|
@ -440,7 +430,7 @@ pub async fn run_client(remote: &str) {
|
||||||
.expect("child did not have a handle to stdout"),
|
.expect("child did not have a handle to stdout"),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(e) = client_sync(&mut reader, &mut writer).await {
|
if let Err(e) = client_sync(&mut reader).await {
|
||||||
eprintln!("Error synchronizing: {:?}", e);
|
eprintln!("Error synchronizing: {:?}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue