From f782e82909559ed6c4594fffba6fe2e1726ca538 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Thu, 22 Jul 2021 15:26:19 -0700 Subject: [PATCH] Fix potential concurrent access condition --- core/stats.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/stats.go b/core/stats.go index 639de1bc2..b2a3fbda1 100644 --- a/core/stats.go +++ b/core/stats.go @@ -100,6 +100,9 @@ func SetViewerIdActive(id string) { func pruneViewerCount() { viewers := make(map[string]time.Time) + l.Lock() + defer l.Unlock() + for viewerId := range _stats.Viewers { viewerLastSeenTime := _stats.Viewers[viewerId] if time.Since(viewerLastSeenTime) < _activeViewerPurgeTimeout {