From 459ff38d30a3ff772826495d690e45f824f1e6cd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 1 Jun 2021 13:56:24 +0100 Subject: [PATCH] otter cli: Use copy_interactive for mgmtchannel proxy Fixes a buffering-induced deadlock. Signed-off-by: Ian Jackson --- src/bin/otter.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 16494e64..9359cd7a 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -1940,12 +1940,19 @@ mod mgmtchannel_proxy { let mut write = write.into_stream()?; let tcmds = thread::spawn(move || { - io::copy(&mut io::stdin(), &mut write) - .context("copy commands") + io_copy_interactive(&mut BufReader::new(io::stdin()), &mut write) + .map_err(|e| match e { + Left(re) => AE::from(re).context("read cmds from stdin"), + Right(we) => AE::from(we).context("forward cmds to servvr"), + }) .unwrap_or_else(|e| e.end_process(8)); }); let tresps = thread::spawn(move || { - io::copy(&mut read, &mut io::stdout()) + io_copy_interactive(&mut read, &mut io::stdout()) + .map_err(|e| match e { + Left(re) => AE::from(re).context("read resps from server"), + Right(we) => AE::from(we).context("forward cmds to stdout"), + }) .context("copy responses") .unwrap_or_else(|e| e.end_process(8)); }); -- 2.30.2