From c8d23f37a40afbb7ccb768241e429a51f94b8e7a Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 25 Jun 2015 22:47:53 -0700 Subject: Fix EOF handling in retry wrapper --- openssl/src/ssl/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'openssl/src/ssl/mod.rs') diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 98611064..a0f97b17 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -758,7 +758,7 @@ pub struct SslStream { impl SslStream { /// Create a new independently owned handle to the underlying socket. pub fn try_clone(&self) -> io::Result> { - Ok(SslStream { + Ok(SslStream { stream: try!(self.stream.try_clone()), ssl: self.ssl.clone(), buf: self.buf.clone(), @@ -851,14 +851,16 @@ impl SslStream { try_ssl_stream!(self.flush()); let len = try_ssl_stream!(self.stream.read(&mut self.buf[..])); if len == 0 { - return Ok(0); + self.ssl.get_rbio().set_eof(true); + } else { + try_ssl_stream!(self.ssl.get_rbio().write_all(&self.buf[..len])); } - try_ssl_stream!(self.ssl.get_rbio().write_all(&self.buf[..len])); } LibSslError::ErrorWantWrite => { try_ssl_stream!(self.flush()) } LibSslError::ErrorZeroReturn => return Err(SslSessionClosed), LibSslError::ErrorSsl => return Err(SslError::get()), - err => panic!("unexpected error {:?}", err), + LibSslError::ErrorSyscall if ret == 0 => return Ok(0), + err => panic!("unexpected error {:?} with ret {}", err, ret), } } } -- cgit v1.2.3