Skip to content

Commit

Permalink
Add notif and related SendZc docs (#299)
Browse files Browse the repository at this point in the history
* Add notif that checks for IORING_CQE_F_NOTIF

* Add extra documentation to SendZc

---------

Co-authored-by: Benedek Thaler <benedek.thaler@wincent.co>
  • Loading branch information
erenon and Benedek Thaler authored Sep 24, 2024
1 parent 0a2283a commit c884322
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions io-uring-test/src/tests/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,10 +1662,12 @@ pub fn test_udp_sendzc_with_dest<S: squeue::EntryMarker, C: cqueue::EntryMarker>
// First SendZc notification
11 => {
assert!(cqueue::more(cqe.flags()));
assert!(!cqueue::notif(cqe.flags()));
}
// Last SendZc notification
0 => {
assert!(!cqueue::more(cqe.flags()));
assert!(cqueue::notif(cqe.flags()));
}
_ => panic!("wrong result for notification"),
},
Expand Down
8 changes: 8 additions & 0 deletions src/cqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,11 @@ pub fn more(flags: u32) -> bool {
pub fn sock_nonempty(flags: u32) -> bool {
flags & sys::IORING_CQE_F_SOCK_NONEMPTY != 0
}

/// Returns whether this completion event is a notification.
///
/// This corresponds to the `IORING_CQE_F_NOTIF` flag,
/// currently used by the [SendZc](crate::opcode::SendZc) operation.
pub fn notif(flags: u32) -> bool {
flags & sys::IORING_CQE_F_NOTIF != 0
}
6 changes: 6 additions & 0 deletions src/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,12 @@ opcode! {
///
/// A fixed (pre-mapped) buffer can optionally be used from pre-mapped buffers that have been
/// previously registered with [`Submitter::register_buffers`](crate::Submitter::register_buffers).
///
/// This operation might result in two completion queue entries.
/// See the `IORING_OP_SEND_ZC` section at [io_uring_enter][] for the exact semantics.
/// Notifications posted by this operation can be checked with [notif](crate::cqueue::notif).
///
/// [io_uring_enter]: https://man7.org/linux/man-pages/man2/io_uring_enter.2.html
pub struct SendZc {
fd: { impl sealed::UseFixed },
buf: { *const u8 },
Expand Down

0 comments on commit c884322

Please sign in to comment.