mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-26 13:31:00 +00:00
ts-appsrc: Fix deadlock during shutdown
The IO Context has to be alive longer than the other parts of the state. Otherwise a deadlock can happen between shutting down the IO context (thread join while the state lock is held) and stuff happening on the IO context (which might take the state lock).
This commit is contained in:
parent
6bd4931120
commit
0792fe4f1a
1 changed files with 17 additions and 7 deletions
|
@ -418,6 +418,11 @@ impl AppSrc {
|
|||
fn unprepare(&self, element: &gst::Element) -> Result<(), ()> {
|
||||
gst_debug!(self.cat, obj: element, "Unpreparing");
|
||||
|
||||
// FIXME: The IO Context has to be alive longer than the other parts
|
||||
// of the state. Otherwise a deadlock can happen between shutting down
|
||||
// the IO context (thread join while the state lock is held) and stuff
|
||||
// happening on the IO context (which might take the state lock).
|
||||
let io_context = {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
||||
if let (&Some(ref pending_future_id), &Some(ref io_context)) =
|
||||
|
@ -426,7 +431,12 @@ impl AppSrc {
|
|||
io_context.release_pending_future_id(*pending_future_id);
|
||||
}
|
||||
|
||||
let io_context = state.io_context.take();
|
||||
*state = State::default();
|
||||
io_context
|
||||
};
|
||||
|
||||
drop(io_context);
|
||||
|
||||
gst_debug!(self.cat, obj: element, "Unprepared");
|
||||
|
||||
|
|
Loading…
Reference in a new issue