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:
@@ -134,9 +134,7 @@ func newCongestionDetector(params congestionDetectorParams) *congestionDetector
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *congestionDetector) Stop() {
|
func (c *congestionDetector) Stop() {
|
||||||
c.stop.Once(func() {
|
c.stop.Break()
|
||||||
close(c.wake)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *congestionDetector) OnCongestionStateChange(f func(congestionState CongestionState, estimatedAvailableChannelCapacity int64)) {
|
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) {
|
func (c *congestionDetector) HandleRTCP(report *rtcp.TransportLayerCC) {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
|
||||||
|
|
||||||
if c.stop.IsBroken() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.feedbackReports.PushBack(feedbackReport{mono.Now(), report})
|
c.feedbackReports.PushBack(feedbackReport{mono.Now(), report})
|
||||||
|
c.lock.Unlock()
|
||||||
|
|
||||||
// notify worker of a new feedback
|
// notify worker of a new feedback
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in New Issue
Block a user