Skip to content

Commit b46582e

Browse files
committed
Don't return shutdown errors during shutdown
1 parent 319b649 commit b46582e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

boring/src/ssl/mod.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,24 @@ impl<S: Read + Write> SslStream<S> {
30543054
match unsafe { ffi::SSL_shutdown(self.ssl.as_ptr()) } {
30553055
0 => Ok(ShutdownResult::Sent),
30563056
1 => Ok(ShutdownResult::Received),
3057-
n => Err(self.make_error(n)),
3057+
n => {
3058+
let e = self.make_error(n);
3059+
3060+
// If boring returns PROTOCOL_IS_SHUTDOWN then the connection
3061+
// has already been shutdown and we can just return Ok(()), as
3062+
// this was exactly what we wanted to do anyway.
3063+
if e.code() == ErrorCode::SSL {
3064+
if let Some(stack) = e.ssl_error() {
3065+
if let Some(first) = stack.errors().first() {
3066+
if first.code() as i32 == boring_sys::SSL_R_PROTOCOL_IS_SHUTDOWN {
3067+
return Ok(ShutdownResult::Received);
3068+
}
3069+
}
3070+
}
3071+
}
3072+
3073+
Err(e)
3074+
}
30583075
}
30593076
}
30603077

0 commit comments

Comments
 (0)