Skip to content

Commit

Permalink
[Fixed] shutdown should only flush io
Browse files Browse the repository at this point in the history
  • Loading branch information
quininer committed Apr 14, 2017
1 parent 4843c68 commit 3d5a365
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tokio-rustls"
version = "0.1.6"
version = "0.1.7"
authors = ["quininer kel <[email protected]>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/quininer/tokio-rustls"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn main() {
#[cfg(unix)]
let stdin = File::new_nb(StdFile(stdin.lock())).unwrap()
.into_io(&handle).unwrap();

#[cfg(unix)]
let stdout = stdout();

Expand Down
6 changes: 3 additions & 3 deletions examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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))
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand All @@ -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()
}
}

0 comments on commit 3d5a365

Please sign in to comment.