Reduce lock scope. (#3167)

Also, do not close channel. stop fuse break will close
the worker and GC cleans up.
This commit is contained in:
Raja Subramanian
2024-11-11 11:38:32 +05:30
committed by GitHub
parent a3f2ca56f9
commit 5109551262
+2 -9
View File
@@ -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 {