From: Ian Jackson Date: Tue, 1 Jun 2021 12:56:24 +0000 (+0100) Subject: otter cli: Use copy_interactive for mgmtchannel proxy X-Git-Tag: otter-0.7.0~150 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=459ff38d30a3ff772826495d690e45f824f1e6cd;p=otter.git otter cli: Use copy_interactive for mgmtchannel proxy Fixes a buffering-induced deadlock. Signed-off-by: Ian Jackson --- 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)); });