Fix place wrong for process_new_packets (#14)
The `wants_read` only changes after `process_new_packets`, which means that not immediately calling `process_new_packets` may cause rustls to cache too much data.
This commit is contained in:
parent
3c9b126993
commit
3be701cefb
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tokio-rustls"
|
||||
version = "0.13.0"
|
||||
version = "0.13.1"
|
||||
authors = ["quininer kel <quininer@live.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/tokio-rs/tls"
|
||||
|
@ -218,7 +218,10 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> Stream<'a, IO, S> {
|
||||
while !self.eof && self.session.wants_read() {
|
||||
match self.read_io(cx) {
|
||||
Poll::Ready(Ok(0)) => self.eof = true,
|
||||
Poll::Ready(Ok(n)) => rdlen += n,
|
||||
Poll::Ready(Ok(n)) => {
|
||||
rdlen += n;
|
||||
self.process_new_packets(cx)?;
|
||||
}
|
||||
Poll::Pending => {
|
||||
read_would_block = true;
|
||||
break;
|
||||
@ -227,8 +230,6 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> Stream<'a, IO, S> {
|
||||
}
|
||||
}
|
||||
|
||||
self.process_new_packets(cx)?;
|
||||
|
||||
return match (self.eof, self.session.is_handshaking()) {
|
||||
(true, true) => {
|
||||
let err = io::Error::new(io::ErrorKind::UnexpectedEof, "tls handshake eof");
|
||||
@ -266,7 +267,7 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncRead for Stream<'a
|
||||
self.eof = true;
|
||||
break;
|
||||
}
|
||||
Poll::Ready(Ok(_)) => (),
|
||||
Poll::Ready(Ok(_)) => self.process_new_packets(cx)?,
|
||||
Poll::Pending => {
|
||||
would_block = true;
|
||||
break;
|
||||
@ -275,8 +276,6 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncRead for Stream<'a
|
||||
}
|
||||
}
|
||||
|
||||
self.process_new_packets(cx)?;
|
||||
|
||||
return match self.session.read(&mut buf[pos..]) {
|
||||
Ok(0) if pos == 0 && would_block => Poll::Pending,
|
||||
Ok(n) if self.eof || would_block => Poll::Ready(Ok(pos + n)),
|
||||
|
Loading…
Reference in New Issue
Block a user