From 6e7d67cccbde6a2b1a54bda840c496244d66f806 Mon Sep 17 00:00:00 2001 From: quininer kel Date: Tue, 21 Feb 2017 19:08:23 +0800 Subject: [PATCH] [Fixed] TlsStream::read ConnectionAborted --- Cargo.toml | 4 ++++ src/lib.rs | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e8ea275..39a0675 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,7 @@ authors = ["quininer kel "] futures = "*" tokio-core = "*" rustls = "*" + +[dev-dependencies] +clap = "*" +webpki-roots = "*" diff --git a/src/lib.rs b/src/lib.rs index b51ae20..197e5cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -161,11 +161,11 @@ impl io::Read for TlsStream where S: Io, C: Session { fn read(&mut self, buf: &mut [u8]) -> io::Result { - loop { - match self.session.read(buf) { - Ok(0) if !self.eof => self.do_io()?, - output => return output - } + self.do_io()?; + if self.eof { + Ok(0) + } else { + self.session.read(buf) } } }