From aefc023dd4abb710bb2381eacfe8077729ffbd88 Mon Sep 17 00:00:00 2001 From: quininer Date: Tue, 15 Aug 2017 22:00:20 +0800 Subject: [PATCH] [Fixed] call only once send_close_notify --- Cargo.toml | 8 ++++++-- README.md | 7 ++++++- src/lib.rs | 7 ++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4372692..796d24f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tokio-rustls" -version = "0.3.0" +version = "0.3.1" authors = ["quininer kel "] license = "MIT/Apache-2.0" repository = "https://github.com/quininer/tokio-rustls" @@ -10,6 +10,10 @@ readme = "README.md" description = "Asynchronous TLS/SSL streams for Tokio using Rustls." categories = ["asynchronous", "cryptography", "network-programming"] +[badges] +travis-ci = { repository = "quininer/tokio-rustls" } +appveyor = { repository = "quininer/tokio-rustls" } + [features] danger = [ "rustls/dangerous_configuration" ] @@ -22,7 +26,7 @@ tokio-proto = { version = "0.1", optional = true } [dev-dependencies] tokio-core = "0.1" clap = "2.20" -webpki-roots = "0.11.0" +webpki-roots = "0.12" [target.'cfg(unix)'.dev-dependencies] tokio-file-unix = "0.4" diff --git a/README.md b/README.md index 4003d57..9612f64 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # tokio-rustls -[![crates](https://img.shields.io/crates/v/tokio-rustls.svg)](https://crates.io/crates/tokio-rustls) [![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/quininer/tokio-rustls/blob/master/LICENSE-MIT) [![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/quininer/tokio-rustls/blob/master/LICENSE-APACHE) [![docs.rs](https://docs.rs/tokio-rustls/badge.svg)](https://docs.rs/tokio-rustls/) +[![travis-ci](https://travis-ci.org/quininer/tokio-rustls.svg?branch=master)](https://travis-ci.org/quininer/tokio-rustls) +[![appveyor](https://ci.appveyor.com/api/projects/status/4ukw15enii50suqi?svg=true)](https://ci.appveyor.com/project/quininer/tokio-rustls) +[![crates](https://img.shields.io/crates/v/tokio-rustls.svg)](https://crates.io/crates/tokio-rustls) +[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/quininer/tokio-rustls/blob/master/LICENSE-MIT) +[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/quininer/tokio-rustls/blob/master/LICENSE-APACHE) +[![docs.rs](https://docs.rs/tokio-rustls/badge.svg)](https://docs.rs/tokio-rustls/) Asynchronous TLS/SSL streams for [Tokio](https://tokio.rs/) using [Rustls](https://github.com/ctz/rustls). diff --git a/src/lib.rs b/src/lib.rs index 5c24c18..978eb6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,6 +165,7 @@ impl Future for MidHandshake /// protocol. #[derive(Debug)] pub struct TlsStream { + is_shutdown: bool, eof: bool, io: S, session: C @@ -186,6 +187,7 @@ impl TlsStream #[inline] pub fn new(io: S, session: C) -> TlsStream { TlsStream { + is_shutdown: false, eof: false, io: io, session: session @@ -310,7 +312,10 @@ impl AsyncWrite for TlsStream C: Session { fn shutdown(&mut self) -> Poll<(), io::Error> { - self.session.send_close_notify(); + if !self.is_shutdown { + self.session.send_close_notify(); + self.is_shutdown = true; + } while self.session.wants_write() { try_nb!(self.session.write_tls(&mut self.io)); }