mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 01:58:51 +02:00
fix(wm): add cmd thread lock acquisition timeouts
After some investigation by @alex-ds13 on Discord it looks like there are times where attempting to gain a lock on the WindowManager inside of read_commands_uds results in the thread becoming blocked when it's not possible to obtain the lock. Instead of waiting indefinitely for a lock, this change ensures that we will wait for at most 1 second before discarding the message so that the command listener loop can continue. Warning logs have been added to inform when a message has been dropped as a result of lock acquisition failure.
This commit is contained in:
@@ -1619,22 +1619,29 @@ pub fn read_commands_uds(wm: &Arc<Mutex<WindowManager>>, mut stream: UnixStream)
|
|||||||
for line in reader.lines() {
|
for line in reader.lines() {
|
||||||
let message = SocketMessage::from_str(&line?)?;
|
let message = SocketMessage::from_str(&line?)?;
|
||||||
|
|
||||||
let mut wm = wm.lock();
|
match wm.try_lock_for(Duration::from_secs(1)) {
|
||||||
|
None => {
|
||||||
if wm.is_paused {
|
tracing::warn!(
|
||||||
return match message {
|
"could not acquire window manager lock, not processing message: {message}"
|
||||||
SocketMessage::TogglePause
|
);
|
||||||
| SocketMessage::State
|
}
|
||||||
| SocketMessage::GlobalState
|
Some(mut wm) => {
|
||||||
| SocketMessage::Stop => Ok(wm.process_command(message, &mut stream)?),
|
if wm.is_paused {
|
||||||
_ => {
|
return match message {
|
||||||
tracing::trace!("ignoring while paused");
|
SocketMessage::TogglePause
|
||||||
Ok(())
|
| SocketMessage::State
|
||||||
|
| SocketMessage::GlobalState
|
||||||
|
| SocketMessage::Stop => Ok(wm.process_command(message, &mut stream)?),
|
||||||
|
_ => {
|
||||||
|
tracing::trace!("ignoring while paused");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
wm.process_command(message.clone(), &mut stream)?;
|
wm.process_command(message.clone(), &mut stream)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user