Fix tight loop on aborted connection (#285)
When the underlying IO returns 0 on read, we must stop polling it since it's closed. Otherwise we'll be stuck in a tight loop. this fixes https://github.com/sfackler/rust-openssl/issues/949
This commit is contained in:
committed by
Carl Lerche
parent
2b59803866
commit
74a5e072fe
@@ -140,7 +140,7 @@ use proto::{self, Config, Prioritized};
|
||||
use bytes::{Buf, Bytes, IntoBuf};
|
||||
use futures::{self, Async, Future, Poll};
|
||||
use http::{Request, Response};
|
||||
use std::{convert, fmt, mem};
|
||||
use std::{convert, fmt, io, mem};
|
||||
use std::time::Duration;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
||||
@@ -1045,6 +1045,12 @@ where
|
||||
|
||||
while rem > 0 {
|
||||
let n = try_nb!(self.inner_mut().read(&mut buf[..rem]));
|
||||
if n == 0 {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::ConnectionReset,
|
||||
"connection closed unexpectedly",
|
||||
).into());
|
||||
}
|
||||
|
||||
if PREFACE[self.pos..self.pos + n] != buf[..n] {
|
||||
// TODO: Should this just write the GO_AWAY frame directly?
|
||||
|
||||
Reference in New Issue
Block a user