diff options
author | Markus Westerlind <marwes91@gmail.com> | 2020-07-20 23:49:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-20 14:49:38 -0700 |
commit | dd28831e1301f09b992dabf5f9e47656ee6d981c (patch) | |
tree | c7287d7e7f7e369376e44f91a7cb2b0eccfc2cb7 /tokio/src/io | |
parent | 6dcce1901a53f099bf10f242943b44010f264171 (diff) |
io: Forward poll_write_buf on BufReader (#2654)
For some yet unknown reason using the default on a wrapped `Bufreader<TcpStream>`
causes the hyper server to sometimes fail to send the entire body in the
response.
This fixes that problem for us and ensures that hyper has a chance to
use vectored IO (making it a good change regardless of the mentioned
bug)
Diffstat (limited to 'tokio/src/io')
-rw-r--r-- | tokio/src/io/util/buf_reader.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tokio/src/io/util/buf_reader.rs b/tokio/src/io/util/buf_reader.rs index 8fe8e83c..a1c5990a 100644 --- a/tokio/src/io/util/buf_reader.rs +++ b/tokio/src/io/util/buf_reader.rs @@ -1,6 +1,7 @@ use crate::io::util::DEFAULT_BUF_SIZE; use crate::io::{AsyncBufRead, AsyncRead, AsyncWrite}; +use bytes::Buf; use pin_project_lite::pin_project; use std::io::{self, Read}; use std::mem::MaybeUninit; @@ -162,6 +163,14 @@ impl<R: AsyncRead + AsyncWrite> AsyncWrite for BufReader<R> { self.get_pin_mut().poll_write(cx, buf) } + fn poll_write_buf<B: Buf>( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + buf: &mut B, + ) -> Poll<io::Result<usize>> { + self.get_pin_mut().poll_write_buf(cx, buf) + } + fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> { self.get_pin_mut().poll_flush(cx) } |