From e488dca1245ee9d5f6bf81023a2839fc53b13852 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 31 Jan 2022 11:06:06 +0100 Subject: [PATCH] Don't return shutdown errors during shutdown --- tokio-boring/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tokio-boring/src/lib.rs b/tokio-boring/src/lib.rs index 0de479c3..20315633 100644 --- a/tokio-boring/src/lib.rs +++ b/tokio-boring/src/lib.rs @@ -254,6 +254,19 @@ where return Poll::Pending; } Err(e) => { + // If boring returns PROTOCOL_IS_SHUTDOWN then the connection + // has already been shutdown and we can just return Ok(()), as + // this was exactly what we wanted to do anyway. + if e.code() == ErrorCode::SSL { + if let Some(stack) = e.ssl_error() { + if let Some(first) = stack.errors.first() { + if first.code() as i32 == boring_sys::SSL_R_PROTOCOL_IS_SHUTDOWN { + return Poll::Ready(Ok(())); + } + } + } + } + return Poll::Ready(Err(e .into_io_error() .unwrap_or_else(|e| io::Error::new(io::ErrorKind::Other, e))));