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
|
|
@ -234,7 +234,7 @@ impl UsrJayOutputOwner for PortalOutput {
|
|||
|
||||
impl UsrWlOutputOwner for PortalOutput {}
|
||||
|
||||
fn maybe_add_display(state: &Rc<PortalState>, name: &str) {
|
||||
async fn maybe_add_display(state: &Rc<PortalState>, name: &str) {
|
||||
let tail = match name.strip_prefix("wayland-") {
|
||||
Some(t) => t,
|
||||
_ => return,
|
||||
|
|
@ -248,7 +248,7 @@ fn maybe_add_display(state: &Rc<PortalState>, name: &str) {
|
|||
_ => return,
|
||||
};
|
||||
let path = format!("{}/{}", state.xrd, name);
|
||||
let con = match UsrCon::new(&state.ring, &state.wheel, &state.eng, &path, num) {
|
||||
let con = match UsrCon::new(&state.ring, &state.wheel, &state.eng, &path, num).await {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
log::error!(
|
||||
|
|
@ -437,7 +437,7 @@ fn add_output(dpy: &Rc<PortalDisplay>, name: u32, version: u32) {
|
|||
}
|
||||
|
||||
pub(super) async fn watch_displays(state: Rc<PortalState>) {
|
||||
let inotify = Rc::new(uapi::inotify_init1(c::IN_CLOEXEC | c::IN_NONBLOCK).unwrap());
|
||||
let inotify = Rc::new(uapi::inotify_init1(c::IN_CLOEXEC).unwrap());
|
||||
if let Err(e) = uapi::inotify_add_watch(inotify.raw(), state.xrd.as_str(), c::IN_CREATE) {
|
||||
log::error!(
|
||||
"Cannot watch directory `{}`: {}",
|
||||
|
|
@ -462,7 +462,7 @@ pub(super) async fn watch_displays(state: Rc<PortalState>) {
|
|||
}
|
||||
};
|
||||
if let Ok(s) = std::str::from_utf8(entry.file_name().as_bytes()) {
|
||||
maybe_add_display(&state, s);
|
||||
maybe_add_display(&state, s).await;
|
||||
}
|
||||
}
|
||||
let mut buf = vec![0u8; 4096];
|
||||
|
|
@ -480,7 +480,7 @@ pub(super) async fn watch_displays(state: Rc<PortalState>) {
|
|||
for event in events {
|
||||
if event.mask.contains(c::IN_CREATE) {
|
||||
if let Ok(s) = std::str::from_utf8(event.name().as_ustr().as_bytes()) {
|
||||
maybe_add_display(&state, s);
|
||||
maybe_add_display(&state, s).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue