From 80fbc2e9ec7fb675ba184921714fc924db5d83a8 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 25 Jul 2018 15:38:02 -0700 Subject: [PATCH] Fix stream draining for http/2 connections #290 --- CHANGES.md | 2 ++ src/pipeline.rs | 2 +- src/server/h2.rs | 4 +++- src/server/h2writer.rs | 8 ++++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2b13657a053..051ab1cc4b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,8 @@ * Missing response header "content-encoding" #421 +* Fix stream draining for http/2 connections #290 + ## [0.7.1] - 2018-07-21 diff --git a/src/pipeline.rs b/src/pipeline.rs index dbe9e58ade0..7c277a587e0 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -409,7 +409,7 @@ struct ProcessResponse { _h: PhantomData, } -#[derive(PartialEq)] +#[derive(PartialEq, Debug)] enum RunningState { Running, Paused, diff --git a/src/server/h2.rs b/src/server/h2.rs index 2322f755aac..e5355a1fd8f 100644 --- a/src/server/h2.rs +++ b/src/server/h2.rs @@ -155,7 +155,9 @@ where } } - if !item.flags.contains(EntryFlags::WRITE_DONE) { + if item.flags.contains(EntryFlags::FINISHED) + && !item.flags.contains(EntryFlags::WRITE_DONE) + { match item.stream.poll_completed(false) { Ok(Async::NotReady) => (), Ok(Async::Ready(_)) => { diff --git a/src/server/h2writer.rs b/src/server/h2writer.rs index c877250ddba..ff87b693e5d 100644 --- a/src/server/h2writer.rs +++ b/src/server/h2writer.rs @@ -245,14 +245,18 @@ impl Writer for H2Writer { let cap = cmp::min(self.buffer.len(), CHUNK_SIZE); stream.reserve_capacity(cap); } else { + if eof { + stream.reserve_capacity(0); + continue; + } self.flags.remove(Flags::RESERVED); - return Ok(Async::NotReady); + return Ok(Async::Ready(())); } } Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)), } } } - Ok(Async::NotReady) + Ok(Async::Ready(())) } }