aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-01-22 15:34:31 -0800
committerSteven Fackler <[email protected]>2016-01-22 15:34:31 -0800
commitb7d3357f3781afba27ab157b81740b39fff2a22e (patch)
tree6e8979c7e672b3181ca8854fe212407106e44b9d /openssl/src
parentMerge pull request #339 from jimmycuadra/allow-raw-pointer-derive (diff)
downloadrust-openssl-b7d3357f3781afba27ab157b81740b39fff2a22e.tar.xz
rust-openssl-b7d3357f3781afba27ab157b81740b39fff2a22e.zip
Fix connect and accept error reporting
We were previously trying to create an error twice so the second wouldn't be correct.
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/ssl/mod.rs36
1 files changed, 16 insertions, 20 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index 7366cc4a..8e6d061d 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -1094,10 +1094,9 @@ impl<S: Read + Write> SslStream<S> {
if ret > 0 {
Ok(stream)
} else {
- 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)),
+ match stream.make_old_error(ret) {
+ Some(err) => Err(err),
+ None => Ok(stream),
}
}
}
@@ -1110,10 +1109,9 @@ impl<S: Read + Write> SslStream<S> {
if ret > 0 {
Ok(stream)
} else {
- 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)),
+ match stream.make_old_error(ret) {
+ Some(err) => Err(err),
+ None => Ok(stream),
}
}
}
@@ -1188,11 +1186,11 @@ impl<S> SslStream<S> {
}
}
- fn make_old_error(&mut self, ret: c_int) -> SslError {
+ fn make_old_error(&mut self, ret: c_int) -> Option<SslError> {
self.check_panic();
match self.ssl.get_error(ret) {
- LibSslError::ErrorSsl => SslError::get(),
+ LibSslError::ErrorSsl => Some(SslError::get()),
LibSslError::ErrorSyscall => {
let err = SslError::get();
let count = match err {
@@ -1201,22 +1199,20 @@ impl<S> SslStream<S> {
};
if count == 0 {
if ret == 0 {
- SslError::StreamError(io::Error::new(io::ErrorKind::ConnectionAborted,
- "unexpected EOF observed"))
+ Some(SslError::StreamError(io::Error::new(io::ErrorKind::ConnectionAborted,
+ "unexpected EOF observed")))
} else {
- SslError::StreamError(self.get_bio_error())
+ Some(SslError::StreamError(self.get_bio_error()))
}
} else {
- err
+ Some(err)
}
}
- LibSslError::ErrorZeroReturn => SslError::SslSessionClosed,
- LibSslError::ErrorWantWrite | LibSslError::ErrorWantRead => {
- SslError::StreamError(self.get_bio_error())
- }
+ LibSslError::ErrorZeroReturn => Some(SslError::SslSessionClosed),
+ LibSslError::ErrorWantWrite | LibSslError::ErrorWantRead => None,
err => {
- SslError::StreamError(io::Error::new(io::ErrorKind::Other,
- format!("unexpected error {:?}", err)))
+ Some(SslError::StreamError(io::Error::new(io::ErrorKind::Other,
+ format!("unexpected error {:?}", err))))
}
}
}