aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/mod.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-12-17 16:54:11 -0800
committerSteven Fackler <[email protected]>2015-12-17 16:54:11 -0800
commit053c924d5a9e9a8dfada3dd6bb754a4db676b062 (patch)
tree8456179b91ebdb7afa0ffb597e5fcfbde786a873 /openssl/src/ssl/mod.rs
parentTravis fixes (diff)
downloadrust-openssl-053c924d5a9e9a8dfada3dd6bb754a4db676b062.tar.xz
rust-openssl-053c924d5a9e9a8dfada3dd6bb754a4db676b062.zip
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
Diffstat (limited to 'openssl/src/ssl/mod.rs')
-rw-r--r--openssl/src/ssl/mod.rs28
1 files changed, 8 insertions, 20 deletions
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<S: Read + Write> SslStream<S> {
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<S: Read + Write> SslStream<S> {
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)),
}
}
}