-
Notifications
You must be signed in to change notification settings - Fork 124
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
Error in examples/readme.rs #87
Comments
|
I use use io_uring::{opcode, types, IoUring};
use std::os::unix::io::AsRawFd;
use std::{fs, io};
use libc::c_void;
fn main() -> io::Result<()> {
let mut ring = IoUring::new(8)?;
let fd = fs::File::open("README.md")?;
let mut buf = vec![0u8; 4096];
let iovec = libc::iovec {
iov_base: buf.as_mut_ptr() as *mut c_void,
iov_len: 4096,
};
let read_e = opcode::Readv::new(types::Fd(fd.as_raw_fd()), &iovec as *const _, 1)
.build()
.user_data(0x42);
// Note that the developer needs to ensure
// that the entry pushed into submission queue is valid (e.g. fd, buffer).
unsafe {
ring.submission()
.push(&read_e)
.expect("submission queue is full");
}
ring.submit_and_wait(1)?;
let cqe = ring.completion().next().expect("completion queue is empty");
assert_eq!(cqe.user_data(), 0x42);
assert!(cqe.result() >= 0, "read error: {}", cqe.result());
println!("{}", cqe.result());
println!("{}", std::str::from_utf8(buf.as_slice()).unwrap());
Ok(())
} |
This was referenced Aug 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I download this repository and run
The program panics and outputs
My OS envirenment is
My rust version is
1.51
andio-uring
version is0.5.1
.The text was updated successfully, but these errors were encountered: