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
|
|
@ -1,17 +1,17 @@
|
|||
use {
|
||||
crate::xcon::Message,
|
||||
crate::{utils::buf::DynamicBuf, xcon::Message},
|
||||
std::rc::Rc,
|
||||
uapi::{AssertPacked, OwnedFd, Packed},
|
||||
};
|
||||
|
||||
pub struct Formatter<'a> {
|
||||
fds: &'a mut Vec<Rc<OwnedFd>>,
|
||||
buf: &'a mut Vec<u8>,
|
||||
buf: &'a mut DynamicBuf,
|
||||
ext_opcode: u8,
|
||||
}
|
||||
|
||||
impl<'a> Formatter<'a> {
|
||||
pub fn new(fds: &'a mut Vec<Rc<OwnedFd>>, buf: &'a mut Vec<u8>, ext_opcode: u8) -> Self {
|
||||
pub fn new(fds: &'a mut Vec<Rc<OwnedFd>>, buf: &'a mut DynamicBuf, ext_opcode: u8) -> Self {
|
||||
Self {
|
||||
fds,
|
||||
buf,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ impl Incoming {
|
|||
const MAX_LENGTH_UNITS: usize = 0x4000 / 4;
|
||||
const MIN_MSG_SIZE: usize = 32;
|
||||
|
||||
let mut msg_buf = self.socket.bufio.buf();
|
||||
let mut msg_buf = self.socket.in_bufs.pop().unwrap_or_default();
|
||||
msg_buf.clear();
|
||||
self.incoming
|
||||
.fill_msg_buf(MIN_MSG_SIZE, &mut msg_buf)
|
||||
.await?;
|
||||
|
|
@ -60,7 +61,7 @@ impl Incoming {
|
|||
if first.serial() < serial {
|
||||
let handler = reply_handlers.pop_front().unwrap();
|
||||
drop(reply_handlers);
|
||||
handler.handle_noreply(&self.socket.bufio)?;
|
||||
handler.handle_noreply(&self.socket)?;
|
||||
reply_handlers = self.socket.reply_handlers.borrow_mut();
|
||||
} else {
|
||||
break;
|
||||
|
|
@ -140,7 +141,7 @@ impl Incoming {
|
|||
Parser::new(msg_buf, fds)
|
||||
};
|
||||
handler.handle_result(
|
||||
&self.socket.bufio,
|
||||
&self.socket,
|
||||
&mut parser,
|
||||
mem::take(&mut msg_buf),
|
||||
)?;
|
||||
|
|
@ -203,7 +204,7 @@ impl Incoming {
|
|||
break 'handle_event;
|
||||
};
|
||||
self.socket.events.push(Event {
|
||||
bufio: self.socket.bufio.clone(),
|
||||
socket: self.socket.clone(),
|
||||
ext,
|
||||
code,
|
||||
buf: mem::take(&mut msg_buf),
|
||||
|
|
@ -212,7 +213,7 @@ impl Incoming {
|
|||
}
|
||||
}
|
||||
if msg_buf.capacity() > 0 {
|
||||
self.socket.bufio.add_buf(msg_buf);
|
||||
self.socket.in_bufs.push(msg_buf);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue