From 98c984f95eef6bb532970f2d62a2591573f59684 Mon Sep 17 00:00:00 2001 From: Michael Baikov Date: Wed, 6 Jul 2022 10:11:05 +0800 Subject: [PATCH] Fix lifetimes for send/recv mmsg results We keep a pointer to slices of receive buffers inside MultHdrs which is used inside MultiResults so those slices need to live at least as long as we want to be able to use MultiResults --- src/sys/socket/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 2680c43fc3..b01e725045 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -1440,7 +1440,7 @@ pub fn sendmsg(fd: RawFd, iov: &[IoSlice<'_>], cmsgs: &[ControlMessage], target_os = "freebsd", target_os = "netbsd", ))] -pub fn sendmmsg<'a, XS, AS, C, I, S>( +pub fn sendmmsg<'a, XS, AS, C, I, S>( fd: RawFd, data: &'a mut MultHdrs, slices: XS, @@ -1451,7 +1451,7 @@ pub fn sendmmsg<'a, XS, AS, C, I, S>( flags: MsgFlags ) -> crate::Result> where - XS: IntoIterator, + XS: IntoIterator, AS: AsRef<[Option]>, I: AsRef<[IoSlice<'a>]> + 'a, C: AsRef<[ControlMessage<'a>]> + 'a, @@ -1606,8 +1606,8 @@ pub fn recvmmsg<'a, XS, S, I>( mut timeout: Option, ) -> crate::Result> where - XS: IntoIterator, - I: AsRef<[IoSliceMut<'a>]>, + XS: IntoIterator, + I: AsRef<[IoSliceMut<'a>]> + 'a, { let mut count = 0; for (i, (slice, mmsghdr)) in slices.into_iter().zip(data.items.iter_mut()).enumerate() {