Skip to content

Commit

Permalink
src: stream: sink: Fix a deadlock when ICE fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso authored and patrickelectric committed Feb 1, 2024
1 parent fccef49 commit 6af8b50
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/stream/sink/webrtc_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,19 @@ impl WebRTCBinInterface for WebRTCSinkWeakProxy {
}
}
Failed | Closed | Disconnected => {
if let Err(error) =
Manager::remove_session(&self.bind, format!("ICE closed with: {state:?}"))
{
error!("Failed removing session {:#?}: {error}", self.bind);
}
let bind = self.bind.clone();
let state = *state;
// Closing the channel from the same thread can cause a deadlock, so we are calling it from another one:
std::thread::Builder::new()
.name("ICEKiller".to_string())
.spawn(move || {
if let Err(error) =
Manager::remove_session(&bind, format!("ICE closed with: {state:?}"))
{
error!("Failed removing session {bind:#?}: {error}");
}
})
.expect("Failed spawing ICEKiller thread");
}
_ => (),
};
Expand Down

0 comments on commit 6af8b50

Please sign in to comment.