Skip to content

Commit

Permalink
Don't return shutdown errors during shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Jan 31, 2022
1 parent 5f327ab commit e488dca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tokio-boring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
Expand Down

0 comments on commit e488dca

Please sign in to comment.