mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-02 17:53:48 +00:00
webrtc: janus: define mutexes ordering
Should help preventing dead locks. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2244>
This commit is contained in:
parent
6082597a56
commit
9742381508
1 changed files with 15 additions and 7 deletions
|
@ -279,6 +279,10 @@ struct State {
|
||||||
leave_room_rx: Option<tokio::sync::oneshot::Receiver<()>>,
|
leave_room_rx: Option<tokio::sync::oneshot::Receiver<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mutex order:
|
||||||
|
// - self.state
|
||||||
|
// - self.settings
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Settings {
|
struct Settings {
|
||||||
janus_endpoint: String,
|
janus_endpoint: String,
|
||||||
|
@ -479,13 +483,15 @@ impl Signaller {
|
||||||
VideoRoomData::Joined(joined) => {
|
VideoRoomData::Joined(joined) => {
|
||||||
let feed_id_changed = {
|
let feed_id_changed = {
|
||||||
let mut feed_id_changed = false;
|
let mut feed_id_changed = false;
|
||||||
let mut settings = self.settings.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
if settings.feed_id.as_ref() != Some(&joined.id) {
|
{
|
||||||
settings.feed_id = Some(joined.id.clone());
|
let mut settings = self.settings.lock().unwrap();
|
||||||
feed_id_changed = true;
|
if settings.feed_id.as_ref() != Some(&joined.id) {
|
||||||
|
settings.feed_id = Some(joined.id.clone());
|
||||||
|
feed_id_changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut state = self.state.lock().unwrap();
|
|
||||||
state.feed_id = Some(joined.id);
|
state.feed_id = Some(joined.id);
|
||||||
|
|
||||||
feed_id_changed
|
feed_id_changed
|
||||||
|
@ -575,8 +581,10 @@ impl Signaller {
|
||||||
|
|
||||||
fn create_session(&self) {
|
fn create_session(&self) {
|
||||||
let transaction = transaction_id();
|
let transaction = transaction_id();
|
||||||
let settings = self.settings.lock().unwrap();
|
let apisecret = {
|
||||||
let apisecret = settings.secret_key.clone();
|
let settings = self.settings.lock().unwrap();
|
||||||
|
settings.secret_key.clone()
|
||||||
|
};
|
||||||
self.send(OutgoingMessage::Create {
|
self.send(OutgoingMessage::Create {
|
||||||
transaction,
|
transaction,
|
||||||
apisecret,
|
apisecret,
|
||||||
|
|
Loading…
Reference in a new issue