Skip to content

Commit a46464d

Browse files
committed
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`.
1 parent 6278fdc commit a46464d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: src/net/tcp/stream.rs

+16
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ impl Read for &TcpStream {
307307
) -> Poll<io::Result<usize>> {
308308
Pin::new(&mut &*self.watcher).poll_read(cx, buf)
309309
}
310+
311+
fn poll_read_vectored(
312+
self: Pin<&mut Self>,
313+
cx: &mut Context<'_>,
314+
bufs: &mut [IoSliceMut<'_>],
315+
) -> Poll<io::Result<usize>> {
316+
Pin::new(&mut &*self.watcher).poll_read_vectored(cx, bufs)
317+
}
310318
}
311319

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

355+
fn poll_write_vectored(
356+
self: Pin<&mut Self>,
357+
cx: &mut Context<'_>,
358+
bufs: &[IoSlice<'_>],
359+
) -> Poll<io::Result<usize>> {
360+
Pin::new(&mut &*self.watcher).poll_write_vectored(cx, bufs)
361+
}
362+
347363
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
348364
Pin::new(&mut &*self.watcher).poll_flush(cx)
349365
}

0 commit comments

Comments
 (0)