Skip to content

Commit

Permalink
fix: missing clear room_map in cluster cause room failed to restart (8…
Browse files Browse the repository at this point in the history
  • Loading branch information
giangndm authored Apr 27, 2024
1 parent 7e84c13 commit ed8106a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/media_core/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ impl<Owner: Debug + Hash + Copy + Clone + Debug + Eq> MediaCluster<Owner> {
match out {
room::Output::Sdn(userdata, control) => Output::Sdn(userdata, control),
room::Output::Endpoint(owners, event) => Output::Endpoint(owners, event),
room::Output::Destroy => {
room::Output::Destroy(room) => {
log::info!("[MediaCluster] remove room index {index}, hash {room}");
self.rooms_map.remove(&room).expect("Should have room with index");
self.rooms.remove_task(index);
Output::Continue
}
Expand Down Expand Up @@ -212,6 +214,7 @@ mod tests {
);
assert_eq!(cluster.pop_output(Instant::now()), None);
assert_eq!(cluster.rooms.tasks(), 1);
assert_eq!(cluster.rooms_map.len(), 1);

// Correct forward to room
let out = cluster.on_sdn_event(
Expand All @@ -235,5 +238,6 @@ mod tests {
assert_eq!(cluster.pop_output(Instant::now()), Some(Output::Continue)); //this is for destroy event
assert_eq!(cluster.pop_output(Instant::now()), None);
assert_eq!(cluster.rooms.tasks(), 0);
assert_eq!(cluster.rooms_map.len(), 0);
}
}
4 changes: 2 additions & 2 deletions packages/media_core/src/cluster/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum Input<Owner> {
pub enum Output<Owner> {
Sdn(ClusterRoomHash, FeaturesControl),
Endpoint(Vec<Owner>, ClusterEndpointEvent),
Destroy,
Destroy(ClusterRoomHash),
}

#[derive(num_enum::TryFromPrimitive)]
Expand Down Expand Up @@ -90,7 +90,7 @@ impl<Owner: Debug + Copy + Clone + Hash + Eq> Task<Input<Owner>, Output<Owner>>
if self.metadata.peers() == 0 && !self.destroyed {
log::info!("[ClusterRoom {}] leave last peer => remove room", self.room);
self.destroyed = true;
Some(Output::Destroy)
Some(Output::Destroy(self.room))
} else {
None
}
Expand Down

0 comments on commit ed8106a

Please sign in to comment.