From 19584b9b6b4252eba0c3564d7c35d6cbf875530e Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Sun, 22 Dec 2024 17:14:44 -0500 Subject: [PATCH] use total count only on logs --- store/concurrency.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/store/concurrency.go b/store/concurrency.go index e5f98a1..8766f01 100644 --- a/store/concurrency.go +++ b/store/concurrency.go @@ -90,12 +90,20 @@ func (cm *ConcurrencyManager) CheckConcurrency(m3uIndex string) bool { } func (cm *ConcurrencyManager) UpdateConcurrency(m3uIndex string, subIndex string, incr bool) { + cm.mu.Lock() + defer cm.mu.Unlock() + if incr { cm.Increment(m3uIndex, subIndex) } else { cm.Decrement(m3uIndex, subIndex) } - count := cm.GetCount(m3uIndex, subIndex) - utils.SafeLogf("Current number of connections for M3U_%s|%s: %d", m3uIndex, subIndex, count) + totalCount := 0 + for subIndex := range cm.count[m3uIndex] { + count := cm.GetCount(m3uIndex, subIndex) + totalCount += count + } + + utils.SafeLogf("Current number of connections for M3U_%s: %d", m3uIndex, totalCount) }