From 872510bd65949afff0c76b9218c0c8db8263e7d5 Mon Sep 17 00:00:00 2001 From: quininer Date: Wed, 6 Nov 2019 21:43:50 +0800 Subject: [PATCH] Fix 0-RTT flush --- src/client.rs | 6 +++++- src/lib.rs | 18 +++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/client.rs b/src/client.rs index 9843f54..a8447bb 100644 --- a/src/client.rs +++ b/src/client.rs @@ -154,7 +154,7 @@ where // end this.state = TlsState::Stream; - data.clear(); + *data = Vec::new(); stream.as_mut_pin().poll_write(cx, buf) } _ => stream.as_mut_pin().poll_write(cx, buf), @@ -171,6 +171,10 @@ where while stream.session.is_handshaking() { futures::ready!(stream.handshake(cx))?; } + + this.state = TlsState::Stream; + let (_, data) = &mut this.early_data; + *data = Vec::new(); } stream.as_mut_pin().poll_flush(cx) diff --git a/src/lib.rs b/src/lib.rs index 9b9fd58..31545dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,20 +1,20 @@ //! Asynchronous TLS/SSL streams for Tokio using [Rustls](https://github.com/ctz/rustls). -pub mod client; mod common; +pub mod client; pub mod server; -use common::Stream; -use futures_core as futures; -use pin_project::{pin_project, project}; -use rustls::{ClientConfig, ClientSession, ServerConfig, ServerSession, Session}; -use std::future::Future; +use std::{ io, mem }; use std::pin::Pin; use std::sync::Arc; -use std::task::{Context, Poll}; -use std::{io, mem}; -use tokio_io::{AsyncRead, AsyncWrite}; +use std::future::Future; +use std::task::{ Context, Poll }; +use futures_core as futures; +use pin_project::{ pin_project, project }; +use tokio_io::{ AsyncRead, AsyncWrite }; use webpki::DNSNameRef; +use rustls::{ ClientConfig, ClientSession, ServerConfig, ServerSession, Session }; +use common::Stream; pub use rustls; pub use webpki;