Skip to content

Commit

Permalink
fix(mmserver): improve shutdown behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed Oct 21, 2024
1 parent e5bf42a commit 0fd7b27
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mm-server/src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub struct Compositor {
ready_once: Option<oneshot::Sender<WakingSender<ControlMessage>>>,
timer: mio_timerfd::TimerFd,
sleeping: bool,
shutting_down: bool,
}

pub struct State {
Expand Down Expand Up @@ -402,6 +403,7 @@ impl Compositor {
ready_once: Some(ready_send),
timer,
sleeping: false,
shutting_down: false,
};

compositor.main_loop(pipe_recv)
Expand Down Expand Up @@ -452,6 +454,7 @@ impl Compositor {
match control_recv.try_recv() {
Ok(ControlMessage::Stop) => {
self.state.handle.kick_clients();
self.shutting_down = true;
trace!("shutting down");

// Usually, TERM doesn't work, because the
Expand Down Expand Up @@ -529,7 +532,9 @@ impl Compositor {
}
}

self.idle()?;
if !self.shutting_down {
self.idle()?;
}

// Check that we haven't timed out waiting for the client to start up.
if self.ready_once.is_some() && self.state.surfaces_ready() {
Expand Down Expand Up @@ -870,6 +875,11 @@ impl Compositor {
fn handle_control_message(&mut self, msg: ControlMessage) -> anyhow::Result<()> {
trace!(?msg, "control message");

if self.shutting_down {
// We're about to shut down, so ignore all messages.
return Ok(());
}

// Attachments get handled asynchronously.
if matches!(msg, ControlMessage::Attach { .. }) {
self.state.pending_attachments.push(msg);
Expand Down

0 comments on commit 0fd7b27

Please sign in to comment.