Skip to content

Commit 4fd3197

Browse files
authored
bug: msghdr lifetime in SendMesgZc (#260)
Box msghdr in `SendMsgZc` struct to ensure it is stable through the lifetime of the op.
1 parent ee8318d commit 4fd3197

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/io/sendmsg_zc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) struct SendMsgZc<T, U> {
1717
#[allow(dead_code)]
1818
socket_addr: Option<Box<SockAddr>>,
1919
msg_control: Option<U>,
20-
msghdr: libc::msghdr,
20+
msghdr: Box<libc::msghdr>,
2121

2222
/// Hold the number of transmitted bytes
2323
bytes: usize,
@@ -32,7 +32,7 @@ impl<T: BoundedBuf, U: BoundedBuf> Op<SendMsgZc<T, U>, MultiCQEFuture> {
3232
) -> io::Result<Self> {
3333
use io_uring::{opcode, types};
3434

35-
let mut msghdr: libc::msghdr = unsafe { std::mem::zeroed() };
35+
let mut msghdr: Box<libc::msghdr> = Box::new(unsafe { std::mem::zeroed() });
3636

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

@@ -84,7 +84,7 @@ impl<T: BoundedBuf, U: BoundedBuf> Op<SendMsgZc<T, U>, MultiCQEFuture> {
8484
|sendmsg_zc| {
8585
opcode::SendMsgZc::new(
8686
types::Fd(sendmsg_zc.fd.raw_fd()),
87-
&sendmsg_zc.msghdr as *const _,
87+
sendmsg_zc.msghdr.as_mut() as *const _,
8888
)
8989
.build()
9090
},

0 commit comments

Comments
 (0)