Skip to content

Commit

Permalink
code review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
neonphog committed Feb 2, 2024
1 parent 84c519c commit 6cc8ace
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion crates/tx5-go-pion/src/data_chan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@ impl DataChannel {

{
let mut lock = self.0.lock().unwrap();
let mut do_swap = false;
if let Ok(core) = &mut *lock {
core.close(err);
do_swap = true;
}
if do_swap {
std::mem::swap(&mut *lock, &mut tmp);
}
std::mem::swap(&mut *lock, &mut tmp);
}

// make sure the above lock is released before this is dropped
Expand Down
6 changes: 5 additions & 1 deletion crates/tx5-go-pion/src/peer_con.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,14 @@ impl PeerConnection {

{
let mut lock = self.0.lock().unwrap();
let mut do_swap = false;
if let Ok(core) = &mut *lock {
core.close(err.clone());
do_swap = true;
}
if do_swap {
std::mem::swap(&mut *lock, &mut tmp);
}
std::mem::swap(&mut *lock, &mut tmp);
}

// make sure the above lock is released before this is dropped
Expand Down

0 comments on commit 6cc8ace

Please sign in to comment.