Skip to content

Commit 8234739

Browse files
michael-grunderwithoutboats
authored andcommittedDec 19, 2019
Slice of IoSliceMut(s) must survive until submit
1 parent c783dec commit 8234739

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎tests/read.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
extern crate test;
33

44
use std::fs::File;
5-
use std::io;
6-
use std::path::PathBuf;
5+
use std::io::{self, IoSliceMut};
76
use std::os::unix::io::{AsRawFd, RawFd};
7+
use std::path::PathBuf;
88

99
const TEXT: &[u8] = b"I really wanna stop
1010
But I just gotta taste for it
@@ -28,8 +28,10 @@ fn read_test() -> io::Result<()> {
2828
path.push("text.txt");
2929
let file = File::open(&path)?;
3030
let mut buf1 = [0; 4096];
31+
3132
unsafe {
32-
prep(&mut io_uring, &mut buf1, file.as_raw_fd())?;
33+
let mut bufs = [io::IoSliceMut::new(&mut buf1)];
34+
prep(&mut io_uring, &mut bufs, file.as_raw_fd())?;
3335
}
3436

3537
let dirt = dirty_stack();
@@ -48,11 +50,10 @@ fn read_test() -> io::Result<()> {
4850
}
4951

5052
#[inline(never)]
51-
unsafe fn prep(ring: &mut iou::IoUring, buf: &mut [u8], fd: RawFd) -> io::Result<()> {
53+
unsafe fn prep(ring: &mut iou::IoUring, bufs: &mut [IoSliceMut], fd: RawFd) -> io::Result<()> {
5254
let mut sq = ring.sq();
5355
let mut sqe = sq.next_sqe().unwrap();
54-
let mut bufs = [io::IoSliceMut::new(buf)];
55-
sqe.prep_read_vectored(fd, &mut bufs, 0);
56+
sqe.prep_read_vectored(fd, bufs, 0);
5657
sqe.set_user_data(0xDEADBEEF);
5758
sq.submit()?;
5859
Ok(())

0 commit comments

Comments
 (0)
Please sign in to comment.