[Fixed] shutdown should only flush io

This commit is contained in:
quininer kel 2017-04-14 12:43:03 +08:00
parent 4843c68019
commit 3d5a36590d
5 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "tokio-rustls"
version = "0.1.6"
version = "0.1.7"
authors = ["quininer kel <quininer@live.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/quininer/tokio-rustls"

View File

@ -7,11 +7,11 @@ Asynchronous TLS/SSL streams for [Tokio](https://tokio.rs/) using
### Basic Structure of a Client
```rust
// ...
use rustls::ClientConfig;
use tokio_rustls::ClientConfigExt;
// ...
let mut config = ClientConfig::new();
config.root_store.add_trust_anchors(&webpki_roots::ROOTS);
let config = Arc::new(config);

View File

@ -63,7 +63,7 @@ fn main() {
let (reader, writer) = stream.split();
io::copy(reader, writer)
})
.map(move |(n, _, _)| println!("Echo: {} - {}", n, addr))
.map(move |(n, ..)| println!("Echo: {} - {}", n, addr))
.map_err(move |err| println!("Error: {:?} - {}", err, addr));
handle.spawn(done);
@ -72,11 +72,11 @@ fn main() {
let done = arc_config.accept_async(stream)
.and_then(|stream| io::write_all(
stream,
"HTTP/1.0 200 ok\r\n\
&b"HTTP/1.0 200 ok\r\n\
Connection: close\r\n\
Content-length: 12\r\n\
\r\n\
Hello world!".as_bytes()
Hello world!"[..]
))
.and_then(|(stream, _)| io::flush(stream))
.map(move |_| println!("Accept: {}", addr))

View File

@ -227,7 +227,7 @@ impl<S, C> io::Write for TlsStream<S, C>
while self.session.wants_write() {
self.session.write_tls(&mut self.io)?;
}
Ok(())
self.io.flush()
}
}
@ -244,7 +244,10 @@ impl<S, C> AsyncWrite for TlsStream<S, C>
{
fn shutdown(&mut self) -> Poll<(), io::Error> {
self.session.send_close_notify();
try_nb!(io::Write::flush(self));
while self.session.wants_write() {
try_nb!(self.session.write_tls(&mut self.io));
}
try_nb!(self.io.flush());
self.io.shutdown()
}
}