Skip to content

Commit

Permalink
Fix matches_unsubscribe()
Browse files Browse the repository at this point in the history
  • Loading branch information
JEnoch committed Oct 13, 2023
1 parent b8ed7bf commit 1e44243
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zenoh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,9 +1452,9 @@ impl Session {
callback: Callback<'static, MatchingStatus>,
) -> ZResult<Arc<MatchingListenerState>> {
let mut state = zwrite!(self.state);
log::trace!("matches_listener({:?})", publisher.key_expr);

let id = state.decl_id_counter.fetch_add(1, Ordering::SeqCst);
log::trace!("matches_listener({:?}) => {id}", publisher.key_expr);
let listener_state = Arc::new(MatchingListenerState {
id,
current: std::sync::Mutex::new(false),
Expand Down Expand Up @@ -1579,8 +1579,10 @@ impl Session {
#[zenoh_macros::unstable]
pub(crate) fn matches_unsubscribe(&self, sid: usize) -> ZResult<()> {
let mut state = zwrite!(self.state);
if let Some(sub_state) = state.subscribers.remove(&sid) {
trace!("matches_unsubscribe({:?})", sub_state);
if state.matching_listeners.remove(&sid).is_some() {
trace!("matches_unsubscribe({sid})");
} else {
bail!("Failed to unsubscribe matching status: unknown id: {sid}")
}
Ok(())
}
Expand Down

0 comments on commit 1e44243

Please sign in to comment.