mirror of
https://github.com/YaLTeR/niri.git
synced 2025-10-05 16:12:47 +02:00
tty: Close DRM device session fd in device_removed()
Same logic as in cosmic-comp.
This commit is contained in:
committed by
Ivan Molodetskikh
parent
e5b0662f48
commit
b7f1e382a2
@@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::fmt::Write;
|
||||
use std::iter::zip;
|
||||
use std::num::NonZeroU64;
|
||||
use std::os::fd::AsFd;
|
||||
use std::os::fd::{AsFd, OwnedFd};
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -756,6 +756,7 @@ impl Tty {
|
||||
}
|
||||
|
||||
let mut device = self.devices.remove(&node).unwrap();
|
||||
let device_fd = device.drm.device_fd().device_fd();
|
||||
|
||||
if let Some(lease_state) = &mut device.drm_lease_state {
|
||||
lease_state.disable_global::<State>();
|
||||
@@ -798,9 +799,25 @@ impl Tty {
|
||||
}
|
||||
|
||||
self.gpu_manager.as_mut().remove_node(&device.render_node);
|
||||
// Trigger re-enumeration in order to remove the device from gpu_manager.
|
||||
let _ = self.gpu_manager.devices();
|
||||
|
||||
niri.event_loop.remove(device.token);
|
||||
|
||||
self.refresh_ipc_outputs(niri);
|
||||
|
||||
drop(device);
|
||||
|
||||
match TryInto::<OwnedFd>::try_into(device_fd) {
|
||||
Ok(fd) => {
|
||||
if let Err(err) = self.session.close(fd) {
|
||||
warn!("error closing DRM device fd: {err:?}");
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
error!("unable to close DRM device cleanly: fd has unexpected references");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn connector_connected(
|
||||
|
Reference in New Issue
Block a user