Variable collision killed stats workers (#670)

This commit is contained in:
Raja Subramanian authored and GitHub committed 2022-05-06 23:42:40 +05:30
1 parent 07b93e2e5b
commit 081b97142f
1 file changed
+5 -5
@@ -52,7 +52,7 @@ func (t *telemetryServiceInternal) ParticipantJoined(
clientInfo *livekit.ClientInfo,
clientMeta *livekit.AnalyticsClientMeta,
) {
w := newStatsWorker(
newWorker := newStatsWorker(
ctx,
t,
livekit.RoomID(room.Sid),
@@ -62,20 +62,20 @@ func (t *telemetryServiceInternal) ParticipantJoined(
)
t.workersMu.Lock()
var free = false
for idx, w := range t.workers {
if w != nil {
for idx, worker := range t.workers {
if worker != nil {
continue
}
free = true
t.workersIdx[livekit.ParticipantID(participant.Sid)] = idx
t.workers[idx] = w
t.workers[idx] = newWorker
break
}
if !free {
t.workersIdx[livekit.ParticipantID(participant.Sid)] = len(t.workers)
t.workers = append(t.workers, w)
t.workers = append(t.workers, newWorker)
}
t.workersMu.Unlock()