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

github.com/sdroege/gst-plugin-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@onestream.live>2023-08-14 11:41:00 +0300
committerSebastian Dröge <sebastian@centricular.com>2023-09-20 19:56:03 +0300
commitacc9fcd8c883d6c8bdfc5cca555a704e4600e6ba (patch)
treedd9a304ef6034db868eeefc3061248f19eb479a5 /utils
parentde0363efad9fefad2b0bad93d6f9ccc81f6f2255 (diff)
fallbackswitch: ensure strict ordering when taking mutexes
Should prevent deadlocks. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1331>
Diffstat (limited to 'utils')
-rw-r--r--utils/fallbackswitch/src/fallbackswitch/imp.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/utils/fallbackswitch/src/fallbackswitch/imp.rs b/utils/fallbackswitch/src/fallbackswitch/imp.rs
index e51b36f5..e74b79f5 100644
--- a/utils/fallbackswitch/src/fallbackswitch/imp.rs
+++ b/utils/fallbackswitch/src/fallbackswitch/imp.rs
@@ -36,6 +36,14 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
)
});
+/* Mutex locking ordering:
+ - self.settings
+ - self.state
+ - self.active_sinkpad
+ - pad.settings
+ - pad.state
+*/
+
#[derive(Debug)]
#[allow(clippy::large_enum_variant)]
enum CapsInfo {
@@ -473,8 +481,8 @@ impl FallbackSwitch {
if active_sinkpad.as_ref() == Some(pad) {
continue;
}
- let pad_state = pad_imp.state.lock();
let pad_settings = pad_imp.settings.lock().clone();
+ let pad_state = pad_imp.state.lock();
#[allow(clippy::collapsible_if)]
/* If this pad has data that arrived within the 'timeout' window
* before the timeout fired, we can switch to it */
@@ -638,8 +646,8 @@ impl FallbackSwitch {
buffer: gst::Buffer,
from_gap: Option<&gst::event::Gap>,
) -> Result<gst::FlowSuccess, gst::FlowError> {
- let mut state = self.state.lock();
let settings = self.settings.lock().clone();
+ let mut state = self.state.lock();
let pad = pad.downcast_ref::<super::FallbackSwitchSinkPad>().unwrap();
let pad_imp = pad.imp();
@@ -1176,8 +1184,8 @@ impl FallbackSwitch {
}
}
- let mut state = self.state.lock();
let settings = self.settings.lock().clone();
+ let mut state = self.state.lock();
min_latency = min_latency.max(settings.min_upstream_latency);
state.upstream_latency = min_latency;
log!(CAT, obj: pad, "Upstream latency {}", min_latency);