diff --git a/src/backends/metal/monitor.rs b/src/backends/metal/monitor.rs index 44c425bd..a9c3504e 100644 --- a/src/backends/metal/monitor.rs +++ b/src/backends/metal/monitor.rs @@ -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) => { diff --git a/src/utils/nonblock.rs b/src/utils/nonblock.rs index d855399b..1cf40bb2 100644 --- a/src/utils/nonblock.rs +++ b/src/utils/nonblock.rs @@ -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(()) }