1
0
Fork 0
forked from wry/wry

xwayland: use io_uring to prevent lockups

See https://gitlab.freedesktop.org/wayland/wayland/-/issues/296
This commit is contained in:
Julian Orth 2022-05-11 21:45:15 +02:00
parent 5573b2a1b7
commit 285724b4f1
13 changed files with 1173 additions and 34 deletions

View file

@ -25,6 +25,7 @@ impl Debug for AsyncEvent {
impl AsyncEvent {
pub fn clear(&self) {
self.triggers.set(0);
self.waker.take();
}

34
src/utils/mmap.rs Normal file
View file

@ -0,0 +1,34 @@
use {
crate::utils::{oserror::OsError, ptr_ext::PtrExt},
std::ptr,
uapi::c,
};
pub struct Mmapped {
pub ptr: *const [u8],
}
pub fn mmap(
len: usize,
prot: c::c_int,
flags: c::c_int,
fd: c::c_int,
offset: c::off_t,
) -> Result<Mmapped, OsError> {
let res = unsafe { c::mmap(ptr::null_mut(), len, prot, flags, fd, offset) };
if res == c::MAP_FAILED {
Err(OsError::default())
} else {
Ok(Mmapped {
ptr: unsafe { std::slice::from_raw_parts(res.cast(), len) },
})
}
}
impl Drop for Mmapped {
fn drop(&mut self) {
unsafe {
c::munmap(self.ptr.deref().as_ptr() as _, self.ptr.deref().len());
}
}
}