Skip to content

Commit

Permalink
Drain compositor_chan on shutdown, causes deadlocks on constellation
Browse files Browse the repository at this point in the history
Constellation blocks on SetId by sending a Port through the compositor
channel and waits for a response.  If the compositor is in the process of
shutting down, it will not look in the queue again.  The compositor
requires the constellation to be shut down first, so it sends a message
to shut down and blocks until the constellation finishes, deadlocking.

Only very short lived executions would've been likely to see this deadlock.
  • Loading branch information
dhedlund committed Dec 15, 2013
1 parent c5d81f1 commit 183c387
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/main/compositing/run.rs
Expand Up @@ -421,4 +421,8 @@ pub fn run_compositor(compositor: &CompositorTask) {
None => {}
Some(ref mut layer) => layer.forget_all_tiles(),
}

// Drain compositor port, sometimes messages contain channels that are blocking
// another task from finishing (i.e. SetIds)
while compositor.port.peek() { compositor.port.recv(); }
}
10 changes: 7 additions & 3 deletions src/components/main/constellation.rs
Expand Up @@ -807,9 +807,13 @@ impl Constellation {
fn set_ids(&self, frame_tree: @mut FrameTree) {
let (port, chan) = comm::stream();
self.compositor_chan.send(SetIds(frame_tree.to_sendable(), chan, self.chan.clone()));
port.try_recv();
for frame in frame_tree.iter() {
frame.pipeline.grant_paint_permission();
match port.try_recv() {
Some(()) => {
for frame in frame_tree.iter() {
frame.pipeline.grant_paint_permission();
}
}
None => {} // message has been discarded, probably shutting down
}
}
}
Expand Down

5 comments on commit 183c387

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at dhedlund@183c387

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging dhedlund/servo/constellation_deadlock = 183c387 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dhedlund/servo/constellation_deadlock = 183c387 merged ok, testing candidate = b81749b

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = b81749b

Please sign in to comment.