Skip to content

Commit

Permalink
Fix lifetimes for send/recv mmsg results
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pacak committed Jul 8, 2022
1 parent 35ee421 commit 9413398
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ pub fn sendmsg<S>(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<S>,
slices: XS,
Expand All @@ -1451,7 +1451,7 @@ pub fn sendmmsg<'a, XS, AS, C, I, S>(
flags: MsgFlags
) -> crate::Result<MultiResults<'a, S>>
where
XS: IntoIterator<Item = I>,
XS: IntoIterator<Item = &'a I>,
AS: AsRef<[Option<S>]>,
I: AsRef<[IoSlice<'a>]> + 'a,
C: AsRef<[ControlMessage<'a>]> + 'a,
Expand Down Expand Up @@ -1606,8 +1606,8 @@ pub fn recvmmsg<'a, XS, S, I>(
mut timeout: Option<crate::sys::time::TimeSpec>,
) -> crate::Result<MultiResults<'a, S>>
where
XS: IntoIterator<Item = I>,
I: AsRef<[IoSliceMut<'a>]>,
XS: IntoIterator<Item = &'a I>,
I: AsRef<[IoSliceMut<'a>]> + 'a,
{
let mut count = 0;
for (i, (slice, mmsghdr)) in slices.into_iter().zip(data.items.iter_mut()).enumerate() {
Expand Down

0 comments on commit 9413398

Please sign in to comment.