io: use io_uring for all io
There should no longer be any - read - write - connect - sendmsg - recvmsg - accept calls in the codebase. Previously we were using a mix of io_uring and these calls which had some negative effects: Since we were using the old system calls, we had to set the file descriptors to non-blocking. But our io_uring code did not handle EAGAIN. This lead to programs sometimes being killed when the wayland IO was actually blocking. Now all file descriptors are set to blocking, but io_uring makes it non-blocking from our perspective. The one exception are evdev files because they are read via libinput and libinput uses the old system calls.
This commit is contained in:
parent
2db0ee8995
commit
9812a02f87
55 changed files with 900 additions and 672 deletions
|
|
@ -8,6 +8,7 @@ use {
|
|||
forker::ForkerError,
|
||||
io_uring::IoUring,
|
||||
utils::{
|
||||
buf::DynamicBuf,
|
||||
buffd::{BufFdIn, BufFdOut},
|
||||
vec_ext::VecExt,
|
||||
},
|
||||
|
|
@ -29,7 +30,7 @@ impl IoIn {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn pop_fd(&mut self) -> Option<OwnedFd> {
|
||||
pub fn pop_fd(&mut self) -> Option<Rc<OwnedFd>> {
|
||||
self.incoming.get_fd().ok()
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +58,7 @@ impl IoIn {
|
|||
|
||||
pub struct IoOut {
|
||||
outgoing: BufFdOut,
|
||||
scratch: Vec<u8>,
|
||||
scratch: DynamicBuf,
|
||||
fds: Vec<Rc<OwnedFd>>,
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ impl IoOut {
|
|||
pub fn new(fd: &Rc<OwnedFd>, ring: &Rc<IoUring>) -> Self {
|
||||
Self {
|
||||
outgoing: BufFdOut::new(fd, ring),
|
||||
scratch: vec![],
|
||||
scratch: DynamicBuf::new(),
|
||||
fds: vec![],
|
||||
}
|
||||
}
|
||||
|
|
@ -83,7 +84,12 @@ impl IoOut {
|
|||
Err(e) => return Err(ForkerError::EncodeFailed(e)),
|
||||
};
|
||||
self.scratch[..mem::size_of_val(&len)].copy_from_slice(uapi::as_bytes(&len));
|
||||
match self.outgoing.flush2(&self.scratch, &mut self.fds).await {
|
||||
let mut buf = self.scratch.borrow();
|
||||
match self
|
||||
.outgoing
|
||||
.flush2(buf.buf.clone(), mem::take(&mut self.fds))
|
||||
.await
|
||||
{
|
||||
Ok(()) => Ok(()),
|
||||
Err(e) => Err(ForkerError::WriteFailed(e)),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue