From fdb81f1f59cf3b4961a9f426ce9bfff10ec54096 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Tue, 19 Nov 2024 15:16:08 -0800 Subject: [PATCH] fix max concurrent web check --- pkg/stats/monitor.go | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/pkg/stats/monitor.go b/pkg/stats/monitor.go index 38755bf9..3ae33819 100644 --- a/pkg/stats/monitor.go +++ b/pkg/stats/monitor.go @@ -164,31 +164,39 @@ func (m *Monitor) canAcceptRequestLocked(req *rpc.StartEgressRequest) ([]interfa } required := req.EstimatedCpu - if required == 0 { - switch r := req.Request.(type) { - case *rpc.StartEgressRequest_RoomComposite: - if m.webRequests.Load() >= m.cpuCostConfig.MaxConcurrentWeb { - return fields, false - } + switch r := req.Request.(type) { + case *rpc.StartEgressRequest_RoomComposite: + if m.webRequests.Load() >= m.cpuCostConfig.MaxConcurrentWeb { + return fields, false + } + if required == 0 { if r.RoomComposite.AudioOnly { required = m.cpuCostConfig.AudioRoomCompositeCpuCost } else { required = m.cpuCostConfig.RoomCompositeCpuCost } - case *rpc.StartEgressRequest_Web: - if m.webRequests.Load() >= m.cpuCostConfig.MaxConcurrentWeb { - return fields, false - } + } + case *rpc.StartEgressRequest_Web: + if m.webRequests.Load() >= m.cpuCostConfig.MaxConcurrentWeb { + return fields, false + } + if required == 0 { if r.Web.AudioOnly { required = m.cpuCostConfig.AudioWebCpuCost } else { required = m.cpuCostConfig.WebCpuCost } - case *rpc.StartEgressRequest_Participant: + } + case *rpc.StartEgressRequest_Participant: + if required == 0 { required = m.cpuCostConfig.ParticipantCpuCost - case *rpc.StartEgressRequest_TrackComposite: + } + case *rpc.StartEgressRequest_TrackComposite: + if required == 0 { required = m.cpuCostConfig.TrackCompositeCpuCost - case *rpc.StartEgressRequest_Track: + } + case *rpc.StartEgressRequest_Track: + if required == 0 { required = m.cpuCostConfig.TrackCpuCost } }