From 9f345cbb3c3f604ea5b08fb24feede7039c1c104 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 13 Mar 2021 12:23:14 +0000 Subject: [PATCH] apitest: handle broken pipe on sse copier quel faff! Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index ba07b369..9f07c7cb 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -148,7 +148,19 @@ impl Ctx { let (mut wpipe, rpipe) = UnixStream::pair()?; thread::spawn(move ||{ eprintln!("copy_to'ing"); - sse.copy_to(&mut wpipe).unwrap(); + match sse.copy_to(&mut wpipe) { + Err(re) => match (||{ + // reqwest::Error won't give us the underlying io::Error :-/ + wpipe.write_all(b"\n")?; + wpipe.flush()?; + Ok::<_,io::Error>(()) + })() { + Err(pe) if pe.kind() == ErrorKind::BrokenPipe => { Ok(()) } + Err(pe) => Err(AE::from(pe)), + Ok(_) => Err(AE::from(re)), + } + Ok(_n) => Ok(()), + }.unwrap(); eprintln!("copy_to'd!"); }); -- 2.30.2