Skip to content

Commit 4a4a448

Browse files
authored
fix: check for ErrorKind::WouldBlock in MidHandshake::SendAlert poll (#47)
1 parent 9fab4e2 commit 4a4a448

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/common/handshake.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ where
5252
mut alert,
5353
error,
5454
} => {
55-
let mut writer = SyncWriteAdapter { io: &mut io, cx };
56-
let _ = alert.write(&mut writer); // best effort
57-
return Poll::Ready(Err((error, io)));
55+
return match alert.write(&mut SyncWriteAdapter { io: &mut io, cx }) {
56+
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
57+
*this = MidHandshake::SendAlert { io, error, alert };
58+
Poll::Pending
59+
}
60+
_ => Poll::Ready(Err((error, io))),
61+
};
5862
}
5963
// Starting the handshake returned an error; fail the future immediately.
6064
MidHandshake::Error { io, error } => return Poll::Ready(Err((error, io))),

0 commit comments

Comments
 (0)