From 5109551262f84d9df926f3af483c8511d06664f4 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Mon, 11 Nov 2024 11:38:32 +0530 Subject: [PATCH] Reduce lock scope. (#3167) Also, do not close channel. stop fuse break will close the worker and GC cleans up. --- pkg/sfu/sendsidebwe/congestion_detector.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/sfu/sendsidebwe/congestion_detector.go b/pkg/sfu/sendsidebwe/congestion_detector.go index 051d8014..d82f2b9d 100644 --- a/pkg/sfu/sendsidebwe/congestion_detector.go +++ b/pkg/sfu/sendsidebwe/congestion_detector.go @@ -134,9 +134,7 @@ func newCongestionDetector(params congestionDetectorParams) *congestionDetector } func (c *congestionDetector) Stop() { - c.stop.Once(func() { - close(c.wake) - }) + c.stop.Break() } func (c *congestionDetector) OnCongestionStateChange(f func(congestionState CongestionState, estimatedAvailableChannelCapacity int64)) { @@ -199,13 +197,8 @@ func (c *congestionDetector) GetEstimatedAvailableChannelCapacity() int64 { func (c *congestionDetector) HandleRTCP(report *rtcp.TransportLayerCC) { c.lock.Lock() - defer c.lock.Unlock() - - if c.stop.IsBroken() { - return - } - c.feedbackReports.PushBack(feedbackReport{mono.Now(), report}) + c.lock.Unlock() // notify worker of a new feedback select {