Skip to content

Revert signature simplification for sendmmsg and recvmmsg #2162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Jan561
Copy link
Contributor

@Jan561 Jan561 commented Oct 6, 2023

Changes the Iterator Item of XS of recvmmsg back to Item = &'a mut AsMut<I> and of sendmmsg back to Item = &'a AsRef<I>.

This partially reverts #2120. Short explanation using recvmmsg:

pub fn recvmmsg<'a, XS, S, I>(
    // elided...
    slices: XS,
) -> crate::Result<MultiResults<'a, S>>
where
    XS: IntoIterator<Item = I>,
    I: AsMut<[IoSliceMut<'a>]>,
{
    for (i, (slice, mmsghdr)) in slices.into_iter().zip(data.items.iter_mut()).enumerate() {
        let p = &mut mmsghdr.msg_hdr;
        p.msg_iov = slice.as_mut().as_mut_ptr().cast();
        p.msg_iovlen = slice.as_mut().len() as _;
        
        // `slice` gets dropped here! If `slice` was not a pointer, `p.msg_iov` could be dangling now!
    }

    // elided ...
}

@Jan561
Copy link
Contributor Author

Jan561 commented Oct 6, 2023

Well, I messed this up. Didn't quite think this through.

Catched this while working on a new API. Not easy to get this right.

@Jan561
Copy link
Contributor Author

Jan561 commented Oct 8, 2023

Closing in favor of #2167.

(I need my master branch to test GHA)

@Jan561 Jan561 closed this Oct 8, 2023
@Jan561 Jan561 mentioned this pull request Feb 14, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant