From 053c924d5a9e9a8dfada3dd6bb754a4db676b062 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 17 Dec 2015 16:54:11 -0800 Subject: Fix nonblocking behavior A new nonblocking socket may not have finished connecting yet, so reads and writes can return ENOTCONNECTED which we should reinterpret into a WantRead or WantWrite Closes #323 --- openssl/src/ssl/mod.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'openssl/src/ssl/mod.rs') diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 183cf19d..d529347f 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -1070,16 +1070,10 @@ impl SslStream { if ret > 0 { Ok(stream) } else { - match stream.make_old_error(ret) { - SslError::StreamError(e) => { - // This is fine - nonblocking sockets will finish the handshake in read/write - if e.kind() == io::ErrorKind::WouldBlock { - Ok(stream) - } else { - Err(SslError::StreamError(e)) - } - } - e => Err(e), + match stream.make_error(ret) { + // This is fine - nonblocking sockets will finish the handshake in read/write + Error::WantRead(..) | Error::WantWrite(..) => Ok(stream), + _ => Err(stream.make_old_error(ret)), } } } @@ -1092,16 +1086,10 @@ impl SslStream { if ret > 0 { Ok(stream) } else { - match stream.make_old_error(ret) { - SslError::StreamError(e) => { - // This is fine - nonblocking sockets will finish the handshake in read/write - if e.kind() == io::ErrorKind::WouldBlock { - Ok(stream) - } else { - Err(SslError::StreamError(e)) - } - } - e => Err(e), + match stream.make_error(ret) { + // This is fine - nonblocking sockets will finish the handshake in read/write + Error::WantRead(..) | Error::WantWrite(..) => Ok(stream), + _ => Err(stream.make_old_error(ret)), } } } -- cgit v1.2.3