From 4a4a448d1a69c02bdff7d04506a76dcf3525813e Mon Sep 17 00:00:00 2001 From: Jacob Rothstein Date: Tue, 5 Mar 2024 22:16:25 -0800 Subject: [PATCH] fix: check for ErrorKind::WouldBlock in MidHandshake::SendAlert poll (#47) --- src/common/handshake.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/handshake.rs b/src/common/handshake.rs index d541f992..e9d4f641 100644 --- a/src/common/handshake.rs +++ b/src/common/handshake.rs @@ -52,9 +52,13 @@ where mut alert, error, } => { - let mut writer = SyncWriteAdapter { io: &mut io, cx }; - let _ = alert.write(&mut writer); // best effort - return Poll::Ready(Err((error, io))); + return match alert.write(&mut SyncWriteAdapter { io: &mut io, cx }) { + Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { + *this = MidHandshake::SendAlert { io, error, alert }; + Poll::Pending + } + _ => Poll::Ready(Err((error, io))), + }; } // Starting the handshake returned an error; fail the future immediately. MidHandshake::Error { io, error } => return Poll::Ready(Err((error, io))),