From 121b5eef19e65acfecb8261d865554e173f2fc78 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 14 Nov 2017 14:56:13 -0800 Subject: [PATCH] fix(lib): fix no_proto dispatcher to flush queue before polling more body --- src/proto/conn.rs | 2 +- src/proto/dispatch.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/proto/conn.rs b/src/proto/conn.rs index 3530bed552..e016e85e38 100644 --- a/src/proto/conn.rs +++ b/src/proto/conn.rs @@ -306,7 +306,7 @@ where I: AsyncRead + AsyncWrite, } } - fn has_queued_body(&self) -> bool { + pub fn has_queued_body(&self) -> bool { match self.state.writing { Writing::Body(_, Some(_)) => true, _ => false, diff --git a/src/proto/dispatch.rs b/src/proto/dispatch.rs index b98f7eee02..2595ffcb08 100644 --- a/src/proto/dispatch.rs +++ b/src/proto/dispatch.rs @@ -148,6 +148,8 @@ where self.conn.close_write(); return Ok(Async::Ready(())); } + } else if self.conn.has_queued_body() { + try_ready!(self.poll_flush()); } else if let Some(mut body) = self.body_rx.take() { let chunk = match body.poll()? { Async::Ready(Some(chunk)) => { @@ -165,7 +167,7 @@ where return Ok(Async::NotReady); } }; - self.conn.write_body(Some(chunk))?; + assert!(self.conn.write_body(Some(chunk))?.is_ready()); } else { return Ok(Async::NotReady); }