rtc: record a room's departure when the participant leaves it (#4913)
* rtc: record a room's departure when the participant leaves it RemoveParticipant removed the participant from the room, closed it, and only then recorded leftAt. CloseIfEmpty runs every second, so a tick landing during the close saw an empty room with a stale or zero departure time and closed it at once: with no departure recorded it compares against the room's creation time and empty_timeout, and with an earlier departure it measures the grace period from that older timestamp. Either way departure_timeout is skipped. Record the departure where the participant is removed, under the lock that already covers it. * rtc: drop the removal wait from the departure timeout test The close signal already pins the interleaving, and the room's close state is decided by the CloseIfEmpty call itself.
This commit is contained in:
+3
-2
@@ -1431,6 +1431,9 @@ func (r *Room) RemoveParticipant(
|
||||
delete(r.hasPublished, identity)
|
||||
delete(r.launchedTrackEgresses, identity)
|
||||
delete(r.agentParticpants, identity)
|
||||
// recorded while the participant is being removed, not after it is closed:
|
||||
// the room is already empty to CloseIfEmpty, which runs every second
|
||||
r.leftAt.Store(time.Now().Unix())
|
||||
if !p.Hidden() {
|
||||
r.protoRoom.NumParticipants--
|
||||
}
|
||||
@@ -1491,8 +1494,6 @@ func (r *Room) RemoveParticipant(
|
||||
// close participant as well
|
||||
_ = p.Close(true, reason, false)
|
||||
|
||||
r.leftAt.Store(time.Now().Unix())
|
||||
|
||||
if sendUpdates {
|
||||
if r.onParticipantChanged != nil {
|
||||
r.onParticipantChanged(p)
|
||||
|
||||
Reference in New Issue
Block a user