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

@ -1,7 +1,7 @@
use {
crate::{
cli::{GlobalArgs, IdleArgs, IdleCmd, IdleSetArgs},
tools::tool_client::{Handle, ToolClient},
tools::tool_client::{with_tool_client, Handle, ToolClient},
utils::{errorfmt::ErrorFmt, stack::Stack},
wire::{jay_compositor, jay_idle, JayIdleId, WlSurfaceId},
},
@ -9,9 +9,10 @@ use {
};
pub fn main(global: GlobalArgs, args: IdleArgs) {
let tc = ToolClient::new(global.log_level.into());
let idle = Idle { tc: tc.clone() };
tc.run(idle.run(args));
with_tool_client(global.log_level.into(), |tc| async move {
let idle = Idle { tc: tc.clone() };
idle.run(args).await;
});
}
struct Idle {

View file

@ -1,7 +1,7 @@
use {
crate::{
cli::{GlobalArgs, LogArgs},
tools::tool_client::{Handle, ToolClient},
tools::tool_client::{with_tool_client, Handle, ToolClient},
utils::errorfmt::ErrorFmt,
wire::{jay_compositor, jay_log_file},
},
@ -18,13 +18,14 @@ use {
};
pub fn main(global: GlobalArgs, args: LogArgs) {
let tc = ToolClient::new(global.log_level.into());
let logger = Rc::new(Log {
tc: tc.clone(),
path: RefCell::new(None),
args,
with_tool_client(global.log_level.into(), |tc| async move {
let logger = Rc::new(Log {
tc: tc.clone(),
path: RefCell::new(None),
args,
});
run(logger).await;
});
tc.run(run(logger));
}
struct Log {

View file

@ -1,11 +1,16 @@
use {
crate::{cli::GlobalArgs, tools::tool_client::ToolClient, wire::jay_compositor::Quit},
crate::{
cli::GlobalArgs,
tools::tool_client::{with_tool_client, ToolClient},
wire::jay_compositor::Quit,
},
std::rc::Rc,
};
pub fn main(global: GlobalArgs) {
let tc = ToolClient::new(global.log_level.into());
tc.run(run(tc.clone()));
with_tool_client(global.log_level.into(), |tc| async move {
run(tc).await;
});
}
async fn run(tc: Rc<ToolClient>) {

View file

@ -2,7 +2,7 @@ use {
crate::{
cli::{GlobalArgs, ScreenshotArgs},
format::XRGB8888,
tools::tool_client::{Handle, ToolClient},
tools::tool_client::{with_tool_client, Handle, ToolClient},
utils::{errorfmt::ErrorFmt, queue::AsyncQueue},
video::{
dmabuf::{DmaBuf, DmaBufPlane},
@ -21,12 +21,13 @@ use {
};
pub fn main(global: GlobalArgs, args: ScreenshotArgs) {
let tc = ToolClient::new(global.log_level.into());
let screenshot = Rc::new(Screenshot {
tc: tc.clone(),
args,
with_tool_client(global.log_level.into(), |tc| async move {
let screenshot = Rc::new(Screenshot {
tc: tc.clone(),
args,
});
run(screenshot).await;
});
tc.run(run(screenshot));
}
struct Screenshot {

View file

@ -2,7 +2,7 @@ use {
crate::{
cli::{GlobalArgs, SeatTestArgs},
ifs::wl_seat::wl_pointer::{PendingScroll, CONTINUOUS, FINGER, WHEEL},
tools::tool_client::{Handle, ToolClient},
tools::tool_client::{with_tool_client, Handle, ToolClient},
wire::{
jay_compositor::{GetSeats, Seat, SeatEvents},
jay_seat_events::{
@ -16,13 +16,14 @@ use {
};
pub fn main(global: GlobalArgs, args: SeatTestArgs) {
let tc = ToolClient::new(global.log_level.into());
let screenshot = Rc::new(SeatTest {
tc: tc.clone(),
args,
names: Default::default(),
with_tool_client(global.log_level.into(), |tc| async move {
let screenshot = Rc::new(SeatTest {
tc: tc.clone(),
args,
names: Default::default(),
});
run(screenshot).await;
});
tc.run(run(screenshot));
}
struct SeatTest {

View file

@ -1,19 +1,20 @@
use {
crate::{
cli::{GlobalArgs, SetLogArgs},
tools::tool_client::ToolClient,
tools::tool_client::{with_tool_client, ToolClient},
wire::jay_compositor::SetLogLevel,
},
std::rc::Rc,
};
pub fn main(global: GlobalArgs, args: SetLogArgs) {
let tc = ToolClient::new(global.log_level.into());
let logger = Rc::new(Log {
tc: tc.clone(),
args,
with_tool_client(global.log_level.into(), |tc| async move {
let logger = Rc::new(Log {
tc: tc.clone(),
args,
});
run(logger).await;
});
tc.run(run(logger));
}
struct Log {

View file

@ -1,12 +1,17 @@
use {
crate::{cli::GlobalArgs, tools::tool_client::ToolClient, wire::jay_compositor::Unlock},
crate::{
cli::GlobalArgs,
tools::tool_client::{with_tool_client, ToolClient},
wire::jay_compositor::Unlock,
},
std::rc::Rc,
};
pub fn main(global: GlobalArgs) {
let tc = ToolClient::new(global.log_level.into());
let logger = Rc::new(Unlocker { tc: tc.clone() });
tc.run(run(logger));
with_tool_client(global.log_level.into(), |tc| async move {
let logger = Rc::new(Unlocker { tc: tc.clone() });
run(logger).await;
});
}
struct Unlocker {