Merge pull request #298 from mahkoh/jorth/drm-blocking
metal: unset O_NONBLOCK for DRM file descriptors
This commit is contained in:
commit
b7b32273be
2 changed files with 17 additions and 2 deletions
|
|
@ -8,7 +8,10 @@ use {
|
|||
dbus::{DbusError, TRUE},
|
||||
udev::UdevDevice,
|
||||
utils::{
|
||||
bitflags::BitflagsExt, cell_ext::CellExt, errorfmt::ErrorFmt, nonblock::set_nonblock,
|
||||
bitflags::BitflagsExt,
|
||||
cell_ext::CellExt,
|
||||
errorfmt::ErrorFmt,
|
||||
nonblock::{set_block, set_nonblock},
|
||||
},
|
||||
video::drm::DrmMaster,
|
||||
wire_dbus::org::freedesktop::login1::session::{
|
||||
|
|
@ -236,6 +239,12 @@ impl MetalBackend {
|
|||
return;
|
||||
}
|
||||
};
|
||||
if let Err(e) = set_block(res.fd.raw()) {
|
||||
log::error!(
|
||||
"Could not set drm file descriptor to blocking: {}",
|
||||
ErrorFmt(e),
|
||||
);
|
||||
}
|
||||
let master = match DrmMaster::new(&slf.state.ring, res.fd.clone()) {
|
||||
Ok(m) => Rc::new(m),
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@ use {crate::utils::oserror::OsError, uapi::c};
|
|||
|
||||
pub fn set_nonblock(fd: c::c_int) -> Result<(), OsError> {
|
||||
let fl = uapi::fcntl_getfl(fd)?;
|
||||
uapi::fcntl_setfl(fd, fl | c::SOCK_NONBLOCK)?;
|
||||
uapi::fcntl_setfl(fd, fl | c::O_NONBLOCK)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_block(fd: c::c_int) -> Result<(), OsError> {
|
||||
let fl = uapi::fcntl_getfl(fd)?;
|
||||
uapi::fcntl_setfl(fd, fl & !c::O_NONBLOCK)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue