From 9c88defe0da2c0f91dfd2bb9fc52820129f7fd73 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Mon, 21 Nov 2022 10:06:15 +0200 Subject: [PATCH] process: expose AW::poll_write_vectored on unix --- tokio/src/io/poll_evented.rs | 2 +- tokio/src/process/mod.rs | 12 ++++++++++++ tokio/src/process/unix/mod.rs | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tokio/src/io/poll_evented.rs b/tokio/src/io/poll_evented.rs index 240d0d4ad40..dfe9ae34cd3 100644 --- a/tokio/src/io/poll_evented.rs +++ b/tokio/src/io/poll_evented.rs @@ -208,7 +208,7 @@ feature! { } } - #[cfg(feature = "net")] + #[cfg(any(feature = "net", feature = "process"))] pub(crate) fn poll_write_vectored<'a>( &'a self, cx: &mut Context<'_>, diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index 7e1e75d3112..66e42127717 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -1329,6 +1329,18 @@ impl AsyncWrite for ChildStdin { fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Pin::new(&mut self.inner).poll_shutdown(cx) } + + fn poll_write_vectored( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + bufs: &[io::IoSlice<'_>], + ) -> Poll> { + Pin::new(&mut self.inner).poll_write_vectored(cx, bufs) + } + + fn is_write_vectored(&self) -> bool { + self.inner.is_write_vectored() + } } impl AsyncRead for ChildStdout { diff --git a/tokio/src/process/unix/mod.rs b/tokio/src/process/unix/mod.rs index 9bbc813fe6d..0345083dc09 100644 --- a/tokio/src/process/unix/mod.rs +++ b/tokio/src/process/unix/mod.rs @@ -182,6 +182,10 @@ impl<'a> io::Write for &'a Pipe { fn flush(&mut self) -> io::Result<()> { (&self.fd).flush() } + + fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { + (&self.fd).write_vectored(bufs) + } } impl AsRawFd for Pipe { @@ -258,6 +262,18 @@ impl AsyncWrite for ChildStdio { fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } + + fn poll_write_vectored( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + bufs: &[io::IoSlice<'_>], + ) -> Poll> { + self.inner.poll_write_vectored(cx, bufs) + } + + fn is_write_vectored(&self) -> bool { + true + } } impl AsyncRead for ChildStdio {