diff options
author | Chirantan Ekbote <chirantan@chromium.org> | 2020-05-19 19:40:20 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-28 07:14:58 +0000 |
commit | 1a9f2a5454481a511257625f985d503c45fd8246 (patch) | |
tree | 0b03744ca2137adb7fac308939fd068d4fd6ea63 /msg_socket | |
parent | 247134fe68f32f45f7a92a7f3181c0a74f713dec (diff) | |
download | crosvm-1a9f2a5454481a511257625f985d503c45fd8246.tar crosvm-1a9f2a5454481a511257625f985d503c45fd8246.tar.gz crosvm-1a9f2a5454481a511257625f985d503c45fd8246.tar.bz2 crosvm-1a9f2a5454481a511257625f985d503c45fd8246.tar.lz crosvm-1a9f2a5454481a511257625f985d503c45fd8246.tar.xz crosvm-1a9f2a5454481a511257625f985d503c45fd8246.tar.zst crosvm-1a9f2a5454481a511257625f985d503c45fd8246.zip |
sys_util: Refactor IntoIovec
The original stated purpose of this trait was to reduce memory allocations but having the `into_iovec` method return a Vec kind of defeats that purpose. Refactor the trait so that it can either convert a T into an iovec or convert a &[T] into a &[iovec]. Implement the trait for VolatileSlice, IoSlice, and IoSliceMut and update all the callers. BUG=none TEST=unit tests Cq-Depend: chromium:2210272 Change-Id: I9d0d617a23030d241d50411f4a5a16e7cba4bcee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2208527 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Diffstat (limited to 'msg_socket')
-rw-r--r-- | msg_socket/src/lib.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/msg_socket/src/lib.rs b/msg_socket/src/lib.rs index 7f5d1a6..540d49d 100644 --- a/msg_socket/src/lib.rs +++ b/msg_socket/src/lib.rs @@ -4,7 +4,7 @@ mod msg_on_socket; -use std::io::Result; +use std::io::{IoSlice, Result}; use std::marker::PhantomData; use std::os::unix::io::{AsRawFd, RawFd}; use std::pin::Pin; @@ -138,7 +138,8 @@ pub trait MsgSender: AsRef<UnixSeqpacket> { handle_eintr!(sock.send(&msg_buffer)) .map_err(|e| MsgError::Send(SysError::new(e.raw_os_error().unwrap_or(0))))?; } else { - sock.send_with_fds(&msg_buffer[..], &fd_buffer[0..fd_size]) + let ioslice = IoSlice::new(&msg_buffer[..]); + sock.send_with_fds(&[ioslice], &fd_buffer[0..fd_size]) .map_err(MsgError::Send)?; } Ok(()) |