From ed80467ff693ae4cad451f597bc69029ac8247b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 27 Feb 2020 12:10:14 +0200 Subject: [PATCH] Make sure to hold MutexGuard for the remainder of the function in various places Not assigning it to a variable would cause it to be dropped immediately and the lock to be released again immediately. --- gstreamer-base/src/aggregator_pad.rs | 2 +- gstreamer-base/src/base_sink.rs | 2 +- gstreamer-base/src/base_src.rs | 2 +- gstreamer-base/src/base_transform.rs | 2 +- gstreamer/src/bin.rs | 2 +- gstreamer/src/element.rs | 12 ++++++------ 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gstreamer-base/src/aggregator_pad.rs b/gstreamer-base/src/aggregator_pad.rs index 915d13e41..a168fabc1 100644 --- a/gstreamer-base/src/aggregator_pad.rs +++ b/gstreamer-base/src/aggregator_pad.rs @@ -21,7 +21,7 @@ impl> AggregatorPadExtManual for O { fn get_segment(&self) -> gst::Segment { unsafe { let ptr: &gst_base_sys::GstAggregatorPad = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&ptr.parent.object.lock); + let _guard = ::utils::MutexGuard::lock(&ptr.parent.object.lock); from_glib_none(&ptr.segment as *const gst_sys::GstSegment) } } diff --git a/gstreamer-base/src/base_sink.rs b/gstreamer-base/src/base_sink.rs index 8eed32cfe..a2dd468e0 100644 --- a/gstreamer-base/src/base_sink.rs +++ b/gstreamer-base/src/base_sink.rs @@ -39,7 +39,7 @@ impl> BaseSinkExtManual for O { fn get_segment(&self) -> gst::Segment { unsafe { let sink: &gst_base_sys::GstBaseSink = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&sink.element.object.lock); + let _guard = ::utils::MutexGuard::lock(&sink.element.object.lock); from_glib_none(&sink.segment as *const _) } } diff --git a/gstreamer-base/src/base_src.rs b/gstreamer-base/src/base_src.rs index 506eb7fdf..2b1225569 100644 --- a/gstreamer-base/src/base_src.rs +++ b/gstreamer-base/src/base_src.rs @@ -29,7 +29,7 @@ impl> BaseSrcExtManual for O { fn get_segment(&self) -> gst::Segment { unsafe { let src: &gst_base_sys::GstBaseSrc = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&src.element.object.lock); + let _guard = ::utils::MutexGuard::lock(&src.element.object.lock); from_glib_none(&src.segment as *const _) } } diff --git a/gstreamer-base/src/base_transform.rs b/gstreamer-base/src/base_transform.rs index 557325061..f783814a7 100644 --- a/gstreamer-base/src/base_transform.rs +++ b/gstreamer-base/src/base_transform.rs @@ -20,7 +20,7 @@ impl> BaseTransformExtManual for O { fn get_segment(&self) -> gst::Segment { unsafe { let trans: &gst_base_sys::GstBaseTransform = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&trans.element.object.lock); + let _guard = ::utils::MutexGuard::lock(&trans.element.object.lock); from_glib_none(&trans.segment as *const _) } } diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index 48427e6a9..ccba7df90 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -157,7 +157,7 @@ impl> GstBinExtManual for O { fn get_children(&self) -> Vec { unsafe { let bin: &gst_sys::GstBin = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&bin.element.object.lock); + let _guard = ::utils::MutexGuard::lock(&bin.element.object.lock); FromGlibPtrContainer::from_glib_none(bin.children) } } diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index eaa5bef4d..ef34e9426 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -502,7 +502,7 @@ impl> ElementExtManual for O { fn get_pads(&self) -> Vec { unsafe { let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&elt.object.lock); + let _guard = ::utils::MutexGuard::lock(&elt.object.lock); FromGlibPtrContainer::from_glib_none(elt.pads) } } @@ -510,7 +510,7 @@ impl> ElementExtManual for O { fn get_sink_pads(&self) -> Vec { unsafe { let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&elt.object.lock); + let _guard = ::utils::MutexGuard::lock(&elt.object.lock); FromGlibPtrContainer::from_glib_none(elt.sinkpads) } } @@ -518,7 +518,7 @@ impl> ElementExtManual for O { fn get_src_pads(&self) -> Vec { unsafe { let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&elt.object.lock); + let _guard = ::utils::MutexGuard::lock(&elt.object.lock); FromGlibPtrContainer::from_glib_none(elt.srcpads) } } @@ -526,7 +526,7 @@ impl> ElementExtManual for O { fn num_pads(&self) -> u16 { unsafe { let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&elt.object.lock); + let _guard = ::utils::MutexGuard::lock(&elt.object.lock); elt.numpads } } @@ -534,7 +534,7 @@ impl> ElementExtManual for O { fn num_sink_pads(&self) -> u16 { unsafe { let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&elt.object.lock); + let _guard = ::utils::MutexGuard::lock(&elt.object.lock); elt.numsinkpads } } @@ -542,7 +542,7 @@ impl> ElementExtManual for O { fn num_src_pads(&self) -> u16 { unsafe { let elt: &gst_sys::GstElement = &*(self.as_ptr() as *const _); - ::utils::MutexGuard::lock(&elt.object.lock); + let _guard = ::utils::MutexGuard::lock(&elt.object.lock); elt.numsrcpads } }