Skip to content
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

Implement the equivalent of io_uring_prep_sendto #309

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

ruuda
Copy link
Contributor

@ruuda ruuda commented Nov 23, 2024

In liburing, there is io_uring_prep_sendto, which is implemented as preparing a regular send followed by set_addr on the same SQE. This was not yet implemented here for Send, so add it.

Fortunately @serzhiio previously implemented the equivalent for SendZc in #228, so it was easy to adapt that for Send. Thanks serzhiio, this saved me a lot of time!

This implements the equivalent of `io_uring_prep_send_set_addr`, which
was already implemented on SendZc, but not yet on the regular Send.
Comment on lines +1008 to +1013
/// Set the destination address, for sending from an unconnected socket.
///
/// When set, `dest_addr_len` must be set as well.
/// See also `man 3 io_uring_prep_send_set_addr`.
dest_addr: *const libc::sockaddr = core::ptr::null(),
dest_addr_len: libc::socklen_t = 0,
Copy link
Contributor Author

@ruuda ruuda Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the generated setters, this generates two of them. This is consistent with SendZc, but I think it would be nicer (for both, although it would be breaking to change SendZc now) to have a single dest_addr(addr: *const libc::sockaddr, addr_len: socklen_t), so it is impossible to forget to specify the length. Is such a thing possible?

Edit: It doesn’t seem so, not without invasive changes to the macro at least. We could do a tuple of course but then the setter is a bit awkward.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not too complicated so I think the status quo is good enough

@quininer quininer merged commit bba7730 into tokio-rs:master Nov 25, 2024
12 checks passed
@quininer
Copy link
Member

Thank you!

@ruuda ruuda deleted the sendto branch November 25, 2024 17:41
@ruuda
Copy link
Contributor Author

ruuda commented Nov 25, 2024

Thanks for the quick release!

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.

2 participants