1
0
Fork 0
forked from wry/wry

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:
Julian Orth 2022-12-31 17:55:58 +01:00
parent 2db0ee8995
commit 9812a02f87
55 changed files with 900 additions and 672 deletions

View file

@ -30,7 +30,7 @@ use {
},
},
utils::{
bitfield::Bitfield, bitflags::BitflagsExt, clonecell::CloneCell,
bitfield::Bitfield, bitflags::BitflagsExt, buf::TypedBuf, clonecell::CloneCell,
copyhashmap::CopyHashMap, errorfmt::ErrorFmt,
},
video::dmabuf::DmaBuf,
@ -798,17 +798,11 @@ impl PwClientNode {
_activation: Rc<PwMemTyped<pw_node_activation>>,
fd: Rc<OwnedFd>,
) {
let mut buf = TypedBuf::<u64>::new();
loop {
// unsafe {
// log::info!("transport = {:#?}", activation.read());
// }
if let Err(e) = self.con.ring.readable(&fd).await {
log::error!(
"Could not wait for transport to become readable: {}",
ErrorFmt(e)
);
return;
}
// log::info!("transport in");
// for port in self.ports.lock().values() {
// for io in port.io_buffers.lock().values() {
@ -820,11 +814,11 @@ impl PwClientNode {
// unsafe {
// log::info!("state = {:#?}", activation.read().state[0]);
// }
let mut n = 0u64;
if let Err(e) = uapi::read(fd.raw(), &mut n) {
if let Err(e) = self.con.ring.read(&fd, buf.buf()).await {
log::error!("Could not read from eventfd: {}", ErrorFmt(e));
return;
}
let n = buf.t();
if n > 1 {
log::warn!("Missed {} transport changes", n - 1);
}