Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@onestream.live>2023-08-14 12:39:49 +0300
committerSebastian Dröge <sebastian@centricular.com>2023-09-20 19:44:52 +0300
commitc9c49dc54caf57c8f8f1ee933c6cba0f2d7a866a (patch)
tree63e8751718b6df9fa03c2606f95634fe191d3831
parent2e4135cefff87e8e960bccefe67637949b819eac (diff)
fallbackswitch: prevent deadlocks in chain function
Calling schedule_timeout() may result in handle_timeout() being called right away, which will need pad state locks which was still hold in chain(). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1329>
-rw-r--r--utils/fallbackswitch/src/fallbackswitch/imp.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/utils/fallbackswitch/src/fallbackswitch/imp.rs b/utils/fallbackswitch/src/fallbackswitch/imp.rs
index b1840c294..c6e734cf0 100644
--- a/utils/fallbackswitch/src/fallbackswitch/imp.rs
+++ b/utils/fallbackswitch/src/fallbackswitch/imp.rs
@@ -829,11 +829,14 @@ impl FallbackSwitch {
is_active = self.active_sinkpad.lock().as_ref() == Some(pad);
}
- let mut pad_state = pad_imp.state.lock();
+ let pad_state = pad_imp.state.lock();
if pad_state.flushing {
debug!(CAT, imp: self, "Flushing");
return Err(gst::FlowError::Flushing);
}
+ // calling schedule_timeout() may result in handle_timeout() being called right away,
+ // which will need pad state locks, so drop it now to prevent deadlocks.
+ drop(pad_state);
if is_active {
if start_running_time
@@ -879,6 +882,8 @@ impl FallbackSwitch {
}
}
+ let mut pad_state = pad_imp.state.lock();
+
if let Some(running_time) = end_running_time {
pad_state.current_running_time = Some(running_time);
}