webrtc-utils: Ensure there is only one cancellable call at a time

Since we only have one canceller at a time, panic if one try to
use it twice in parallel.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1262>
This commit is contained in:
Olivier Crête 2023-06-27 14:22:52 -04:00 committed by GStreamer Marge Bot
parent 817b60a758
commit 08b6251a7a

View file

@ -127,6 +127,13 @@ where
let (abort_handle, abort_registration) = future::AbortHandle::new_pair();
{
let mut canceller_guard = canceller.lock().unwrap();
if canceller_guard.is_some() {
return Err(WaitError::FutureError(gst::error_msg!(
gst::ResourceError::Failed,
["Old Canceller should not exist"]
)));
}
canceller_guard.replace(abort_handle);
drop(canceller_guard);
}