perf(http2): reduce empty EOS frames if end is already known
This commit is contained in:
@@ -191,8 +191,8 @@ impl Error {
|
||||
Error::new(Kind::Body, Some(cause.into()))
|
||||
}
|
||||
|
||||
pub(crate) fn new_body_write(cause: io::Error) -> Error {
|
||||
Error::new(Kind::BodyWrite, Some(Box::new(cause)))
|
||||
pub(crate) fn new_body_write<E: Into<Cause>>(cause: E) -> Error {
|
||||
Error::new(Kind::BodyWrite, Some(cause.into()))
|
||||
}
|
||||
|
||||
pub(crate) fn new_user_unsupported_version() -> Error {
|
||||
|
||||
@@ -64,7 +64,8 @@ where
|
||||
// parked Connection.
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let fut = conn
|
||||
.map_err(|e| debug!("client h2 connection error: {}", e))
|
||||
.inspect(|_| trace!("connection complete"))
|
||||
.map_err(|e| debug!("connection error: {}", e))
|
||||
.select2(rx)
|
||||
.then(|res| match res {
|
||||
Ok(Either::A(((), _))) |
|
||||
@@ -132,7 +133,7 @@ where
|
||||
|
||||
Ok(Async::Ready(None)) |
|
||||
Err(_) => {
|
||||
trace!("client tx dropped");
|
||||
trace!("client::dispatch::Sender dropped");
|
||||
return Ok(Async::Ready(()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,14 +71,25 @@ where
|
||||
// - call self.body_tx.poll_capacity(), return if NotReady
|
||||
match self.stream.poll_data() {
|
||||
Ok(Async::Ready(Some(chunk))) => {
|
||||
trace!("send body chunk: {}B", chunk.as_ref().len());
|
||||
self.body_tx.send_data(SendBuf(Some(Cursor::new(chunk))), false)
|
||||
.map_err(::Error::new_h2)?;
|
||||
let is_eos = self.stream.is_end_stream();
|
||||
trace!(
|
||||
"send body chunk: {} bytes, eos={}",
|
||||
chunk.as_ref().len(),
|
||||
is_eos,
|
||||
);
|
||||
|
||||
let buf = SendBuf(Some(Cursor::new(chunk)));
|
||||
self.body_tx.send_data(buf, is_eos)
|
||||
.map_err(::Error::new_body_write)?;
|
||||
|
||||
if is_eos {
|
||||
return Ok(Async::Ready(()))
|
||||
}
|
||||
},
|
||||
Ok(Async::Ready(None)) => {
|
||||
trace!("send body eos");
|
||||
self.body_tx.send_data(SendBuf(None), true)
|
||||
.map_err(::Error::new_h2)?;
|
||||
.map_err(::Error::new_body_write)?;
|
||||
return Ok(Async::Ready(()));
|
||||
},
|
||||
Ok(Async::NotReady) => return Ok(Async::NotReady),
|
||||
|
||||
Reference in New Issue
Block a user