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
|
|
@ -211,7 +211,7 @@ fn dup_fd(fd: c::c_int) -> Result<Rc<OwnedFd>, MetalError> {
|
|||
}
|
||||
|
||||
pub async fn create(state: &Rc<State>) -> Result<Rc<MetalBackend>, MetalError> {
|
||||
let socket = match state.dbus.system() {
|
||||
let socket = match state.dbus.system().await {
|
||||
Ok(s) => s,
|
||||
Err(e) => return Err(MetalError::DbusSystemSocket(e)),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -213,11 +213,7 @@ impl MetalBackend {
|
|||
return;
|
||||
}
|
||||
};
|
||||
if let Err(e) = set_nonblock(res.fd.raw()) {
|
||||
log::error!("Could set drm fd to non-blocking: {}", ErrorFmt(e));
|
||||
return;
|
||||
}
|
||||
let master = Rc::new(DrmMaster::new(res.fd.clone()));
|
||||
let master = Rc::new(DrmMaster::new(&slf.state.ring, res.fd.clone()));
|
||||
let dev = match slf.create_drm_device(dev, &master) {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -1214,18 +1214,12 @@ impl MetalBackend {
|
|||
|
||||
async fn handle_drm_events(self: Rc<Self>, dev: Rc<MetalDrmDeviceData>) {
|
||||
loop {
|
||||
if let Err(e) = self.state.ring.readable(dev.dev.master.fd()).await {
|
||||
log::error!("Could not register the DRM fd for reading: {}", ErrorFmt(e));
|
||||
break;
|
||||
}
|
||||
loop {
|
||||
match dev.dev.master.event() {
|
||||
Ok(Some(e)) => self.handle_drm_event(e, &dev),
|
||||
Ok(None) => break,
|
||||
Err(e) => {
|
||||
log::error!("Could not read DRM event: {}", ErrorFmt(e));
|
||||
return;
|
||||
}
|
||||
match dev.dev.master.event().await {
|
||||
Ok(Some(e)) => self.handle_drm_event(e, &dev),
|
||||
Ok(None) => break,
|
||||
Err(e) => {
|
||||
log::error!("Could not read DRM event: {}", ErrorFmt(e));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue