Skip to content

Commit

Permalink
Bug: iovec array not stable during sendmsg_zc op (#257)
Browse files Browse the repository at this point in the history
The iovec array must be stable until either: 
  - Operation completion, or
- not doing IORING_SETUP_SQPOLL, and feature IORING_FEAT_SUBMIT_STABLE
is present

This fix takes the simple option of holding the iovec until operation is
completed.
  • Loading branch information
ollie-etl authored Mar 2, 2023
1 parent f562364 commit 1a089de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/io/sendmsg_zc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub(crate) struct SendMsgZc<T, U> {
#[allow(dead_code)]
io_bufs: Vec<T>,
#[allow(dead_code)]
io_slices: Vec<IoSlice<'static>>,
#[allow(dead_code)]
socket_addr: Option<Box<SockAddr>>,
msg_control: Option<U>,
msghdr: libc::msghdr,
Expand All @@ -32,7 +34,7 @@ impl<T: BoundedBuf, U: BoundedBuf> Op<SendMsgZc<T, U>, MultiCQEFuture> {

let mut msghdr: libc::msghdr = unsafe { std::mem::zeroed() };

let mut io_slices: Vec<IoSlice> = Vec::with_capacity(io_bufs.len());
let mut io_slices: Vec<IoSlice<'static>> = Vec::with_capacity(io_bufs.len());

for io_buf in &io_bufs {
io_slices.push(IoSlice::new(unsafe {
Expand Down Expand Up @@ -74,6 +76,7 @@ impl<T: BoundedBuf, U: BoundedBuf> Op<SendMsgZc<T, U>, MultiCQEFuture> {
fd: fd.clone(),
io_bufs,
socket_addr,
io_slices,
msg_control,
msghdr,
bytes: 0,
Expand Down

0 comments on commit 1a089de

Please sign in to comment.