Skip to content

Commit

Permalink
Reduce deadlock potential of leave-* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
leonqadirie committed Feb 7, 2024
1 parent 35fd146 commit 38b05c3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ractor/src/pg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ pub fn leave_scoped(scope: ScopeName, group: GroupName, actors: Vec<ActorCell>)
// if the scope and group tuple is empty, remove it
if mut_ref.is_empty() {
occupied_map.remove();
}

// remove the group and possibly the scope from the monitor's index
if let Some(mut groups_in_scope) = monitor_idx {
groups_in_scope.retain(|group_name| group_name != &group);
if groups_in_scope.is_empty() {
// drop the `RefMut` to prevent a `DashMap` deadlock
drop(groups_in_scope);
monitor.index.remove(&scope);
}
// remove the group and possibly the scope from the monitor's index
if let Some(mut groups_in_scope) = monitor_idx {
groups_in_scope.retain(|group_name| group_name != &group);
if groups_in_scope.is_empty() {
// drop the `RefMut` to prevent a `DashMap` deadlock
drop(groups_in_scope);
monitor.index.remove(&scope);
}
}

Expand Down

0 comments on commit 38b05c3

Please sign in to comment.