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]
|
[package]
|
||||||
name = "tokio-rustls"
|
name = "tokio-rustls"
|
||||||
version = "0.13.0"
|
version = "0.13.1"
|
||||||
authors = ["quininer kel <quininer@live.com>"]
|
authors = ["quininer kel <quininer@live.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
repository = "https://github.com/tokio-rs/tls"
|
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() {
|
while !self.eof && self.session.wants_read() {
|
||||||
match self.read_io(cx) {
|
match self.read_io(cx) {
|
||||||
Poll::Ready(Ok(0)) => self.eof = true,
|
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 => {
|
Poll::Pending => {
|
||||||
read_would_block = true;
|
read_would_block = true;
|
||||||
break;
|
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()) {
|
return match (self.eof, self.session.is_handshaking()) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
let err = io::Error::new(io::ErrorKind::UnexpectedEof, "tls handshake eof");
|
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;
|
self.eof = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Poll::Ready(Ok(_)) => (),
|
Poll::Ready(Ok(_)) => self.process_new_packets(cx)?,
|
||||||
Poll::Pending => {
|
Poll::Pending => {
|
||||||
would_block = true;
|
would_block = true;
|
||||||
break;
|
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..]) {
|
return match self.session.read(&mut buf[pos..]) {
|
||||||
Ok(0) if pos == 0 && would_block => Poll::Pending,
|
Ok(0) if pos == 0 && would_block => Poll::Pending,
|
||||||
Ok(n) if self.eof || would_block => Poll::Ready(Ok(pos + n)),
|
Ok(n) if self.eof || would_block => Poll::Ready(Ok(pos + n)),
|
||||||
|
Loading…
Reference in New Issue
Block a user