From 08b6251a7a0feb71c918326acc62b2b512e24e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Tue, 27 Jun 2023 14:22:52 -0400 Subject: [PATCH] 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: --- net/webrtc/src/utils.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/webrtc/src/utils.rs b/net/webrtc/src/utils.rs index 12e2db27..33cfa3c1 100644 --- a/net/webrtc/src/utils.rs +++ b/net/webrtc/src/utils.rs @@ -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); }