From 1a32439d7e8e2494cbc9f90a47e9c5d3e871574a Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Fri, 18 Aug 2023 02:00:43 +0530 Subject: [PATCH] Ensure older session does not clobeer newer session. (#1974) --- pkg/rtc/participant_signal.go | 3 +-- pkg/rtc/room.go | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/rtc/participant_signal.go b/pkg/rtc/participant_signal.go index a9ae4dfab..e634fa573 100644 --- a/pkg/rtc/participant_signal.go +++ b/pkg/rtc/participant_signal.go @@ -58,8 +58,7 @@ func (p *ParticipantImpl) SendJoinResponse(joinResponse *livekit.JoinResponse) e return err } - // update state after to sending message, so that no participant updates could slip through before JoinResponse is - // sent + // update state after sending message, so that no participant updates could slip through before JoinResponse is sent p.updateLock.Lock() if p.State() == livekit.ParticipantInfo_JOINING { p.updateState(livekit.ParticipantInfo_JOINED) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 7d8a12a03..f614f8979 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -1069,6 +1069,15 @@ func (r *Room) pushAndDequeueUpdates(pi *livekit.ParticipantInfo, isImmediate bo return nil } } + } else { + ep := r.GetParticipant(identity) + if ep != nil { + epi := ep.ToProto() + if epi.JoinedAt > pi.JoinedAt { + // older session update, newer session has already become active, so nothing to do + return nil + } + } } if shouldSend {