From ea2fa30cf86ca9a3765c81ec144db2a84fae96fa Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Sun, 28 Jan 2024 23:12:33 +0530 Subject: [PATCH] Plug worker leaks (#2422) Thank you @paulwe --- pkg/rtc/room.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index c6c7609f5..745ae9f4f 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -574,6 +574,7 @@ func (r *Room) RemoveParticipant(identity livekit.ParticipantIdentity, pID livek r.lock.Unlock() return } + r.removeParticipantWorkerLocked(p) if pID != "" && p.ID() != pID { // participant session has been replaced @@ -582,7 +583,6 @@ func (r *Room) RemoveParticipant(identity livekit.ParticipantIdentity, pID livek } delete(r.participants, identity) - r.removeParticipantWorkerLocked(p) delete(r.participantOpts, identity) delete(r.participantRequestSources, identity) delete(r.hasPublished, identity) @@ -1529,6 +1529,7 @@ func (r *Room) removeParticipantWorkerLocked(p types.LocalParticipant) { for idx, participant := range pw.participants { if p == participant { pw.participants[idx] = pw.participants[n-1] + pw.participants[n-1] = nil pw.participants = pw.participants[:n-1] break }