Skip to content

Commit ca83671

Browse files
committed
terminate track actors after participants leave
1 parent 897be5d commit ca83671

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

pulsebeam/src/controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl ControllerActor {
103103
offer: String,
104104
) -> Result<String, ControllerError> {
105105
let offer = SdpOffer::from_sdp_string(&offer)?;
106-
tracing::info!("{offer}");
106+
tracing::debug!("{offer}");
107107
let mut rtc_config = RtcConfig::new()
108108
.clear_codecs()
109109
// TODO: enable bwe
@@ -151,7 +151,7 @@ impl ControllerActor {
151151
.await
152152
.map_err(|_| ControllerError::ServiceUnavailable)?;
153153

154-
tracing::info!("{answer}");
154+
tracing::debug!("{answer}");
155155
Ok(answer.to_sdp_string())
156156
}
157157

pulsebeam/src/participant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ impl actor::Actor for ParticipantActor {
161161
self.handle_published_tracks(ctx, tracks.as_ref());
162162
}
163163
ParticipantControlMessage::TracksUnpublished(track_ids) => {
164+
tracing::info!("tracks unpublished: {track_ids:?}");
164165
for track_id in track_ids.keys() {
165166
let track = if let Some(track) =
166167
self.available_video_tracks.remove(&track_id.internal)

pulsebeam/src/room.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,13 @@ impl RoomActor {
181181
return;
182182
};
183183

184-
for track_id in participant.tracks.keys() {
184+
// Explicitly terminate the tracks owned by the leaving participant.
185+
// This prevents "zombie" track actors from causing race conditions if the participant rejoins quickly.
186+
for (track_id, track_handle) in &participant.tracks {
187+
// Remove the track from the central registry.
185188
self.state.tracks.remove(track_id);
189+
// Terminate the track actor itself.
190+
let _ = track_handle.terminate().await;
186191
}
187192

188193
self.system_ctx

0 commit comments

Comments
 (0)