use write_io
instead of handshake
This commit is contained in:
parent
7864945694
commit
9a161beb87
@ -56,8 +56,8 @@ where
|
|||||||
futures::ready!(stream.handshake(cx))?;
|
futures::ready!(stream.handshake(cx))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if stream.session.wants_write() {
|
while stream.session.wants_write() {
|
||||||
futures::ready!(stream.handshake(cx))?;
|
futures::ready!(stream.write_io(cx))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> Stream<'a, IO, S> {
|
|||||||
Pin::new(self)
|
Pin::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_new_packets(&mut self, cx: &mut Context) -> io::Result<()> {
|
pub fn process_new_packets(&mut self, cx: &mut Context) -> io::Result<()> {
|
||||||
self.session.process_new_packets()
|
self.session.process_new_packets()
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
// In case we have an alert to send describing this error,
|
// In case we have an alert to send describing this error,
|
||||||
@ -45,7 +45,7 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> Stream<'a, IO, S> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
|
pub fn read_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
|
||||||
struct Reader<'a, 'b, T> {
|
struct Reader<'a, 'b, T> {
|
||||||
io: &'a mut T,
|
io: &'a mut T,
|
||||||
cx: &'a mut Context<'b>
|
cx: &'a mut Context<'b>
|
||||||
@ -71,7 +71,7 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> Stream<'a, IO, S> {
|
|||||||
Poll::Ready(Ok(n))
|
Poll::Ready(Ok(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
|
pub fn write_io(&mut self, cx: &mut Context) -> Poll<io::Result<usize>> {
|
||||||
struct Writer<'a, 'b, T> {
|
struct Writer<'a, 'b, T> {
|
||||||
io: &'a mut T,
|
io: &'a mut T,
|
||||||
cx: &'a mut Context<'b>
|
cx: &'a mut Context<'b>
|
||||||
|
@ -191,8 +191,8 @@ fn do_handshake(client: &mut ClientSession, server: &mut ServerSession, cx: &mut
|
|||||||
ready!(stream.handshake(cx))?;
|
ready!(stream.handshake(cx))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if stream.session.wants_write() {
|
while stream.session.wants_write() {
|
||||||
ready!(stream.handshake(cx))?;
|
ready!(stream.write_io(cx))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Poll::Ready(Ok(()))
|
Poll::Ready(Ok(()))
|
||||||
|
@ -51,8 +51,8 @@ where
|
|||||||
futures::ready!(stream.handshake(cx))?;
|
futures::ready!(stream.handshake(cx))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if stream.session.wants_write() {
|
while stream.session.wants_write() {
|
||||||
futures::ready!(stream.handshake(cx))?;
|
futures::ready!(stream.write_io(cx))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ async fn send(config: Arc<ClientConfig>, addr: SocketAddr, data: &[u8])
|
|||||||
stream.write_all(data).await?;
|
stream.write_all(data).await?;
|
||||||
stream.flush().await?;
|
stream.flush().await?;
|
||||||
|
|
||||||
// sleep 3s
|
// sleep 1s
|
||||||
//
|
//
|
||||||
// see https://www.mail-archive.com/openssl-users@openssl.org/msg84451.html
|
// see https://www.mail-archive.com/openssl-users@openssl.org/msg84451.html
|
||||||
let sleep3 = delay_for(Duration::from_secs(3));
|
let sleep1 = delay_for(Duration::from_secs(1));
|
||||||
let mut stream = match future::select(Read1(stream), sleep3).await {
|
let mut stream = match future::select(Read1(stream), sleep1).await {
|
||||||
future::Either::Right((_, Read1(stream))) => stream,
|
future::Either::Right((_, Read1(stream))) => stream,
|
||||||
future::Either::Left((Err(err), _)) => return Err(err),
|
future::Either::Left((Err(err), _)) => return Err(err),
|
||||||
future::Either::Left((Ok(_), _)) => unreachable!(),
|
future::Either::Left((Ok(_), _)) => unreachable!(),
|
||||||
@ -77,7 +77,7 @@ async fn test_0rtt() -> io::Result<()> {
|
|||||||
.map(DropKill)?;
|
.map(DropKill)?;
|
||||||
|
|
||||||
// wait openssl server
|
// wait openssl server
|
||||||
delay_for(Duration::from_secs(3)).await;
|
delay_for(Duration::from_secs(1)).await;
|
||||||
|
|
||||||
let mut config = ClientConfig::new();
|
let mut config = ClientConfig::new();
|
||||||
let mut chain = BufReader::new(Cursor::new(include_str!("end.chain")));
|
let mut chain = BufReader::new(Cursor::new(include_str!("end.chain")));
|
||||||
|
Loading…
Reference in New Issue
Block a user