Skip to content

Commit

Permalink
fix: add a comment to explain why the lock is reacquired
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfo committed Nov 6, 2024
1 parent 3961ff4 commit d889d31
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions zenoh/src/api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,11 @@ impl SessionInner {
drop(state);
#[cfg(feature = "unstable")]
{
// the lock from the outer scope cannot be reused because the declared variables
// would be undeclared at the end of the block, with the lock held, and we want
// to avoid that; so we reacquire the lock in the block
// anyway, it doesn't really matter, and this code will be cleaned up when the APIs
// will be stabilized.
let mut state = zwrite!(self.state);
let _tokens = std::mem::take(&mut state.tokens);
let _matching_listeners = std::mem::take(&mut state.matching_listeners);
Expand Down

0 comments on commit d889d31

Please sign in to comment.