Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix vectored IO for TcpStream
Implements `Write::poll_write_vectored` and `Read::poll_read_vectored` on `TcpStream` using the vectored IO methods on the underlying stream. Previously, the trait's default implementation was used, which just called `poll_write` and `poll_read` once for each `IoSlice`.
  • Loading branch information
theo3 committed Jan 19, 2021
commit a46464deab149387bf4002ff35cf74ce480243a3
16 changes: 16 additions & 0 deletions src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ impl Read for &TcpStream {
) -> Poll<io::Result<usize>> {
Pin::new(&mut &*self.watcher).poll_read(cx, buf)
}

fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
) -> Poll<io::Result<usize>> {
Pin::new(&mut &*self.watcher).poll_read_vectored(cx, bufs)
}
}

impl Write for TcpStream {
Expand Down Expand Up @@ -344,6 +352,14 @@ impl Write for &TcpStream {
Pin::new(&mut &*self.watcher).poll_write(cx, buf)
}

fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<io::Result<usize>> {
Pin::new(&mut &*self.watcher).poll_write_vectored(cx, bufs)
}

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Pin::new(&mut &*self.watcher).poll_flush(cx)
}
Expand Down