mirror of
https://github.com/livekit/livekit.git
synced 2026-07-31 00:49:39 +00:00
Call Broadcast in lock scope. (#3625)
* Call Broadcast in lock scope. Seems like there is a possible window where things can hang forever if a goroutine enters the Wait) after the lock is released but before Broadcast gets called, it will never see that broadcast and will hang forever. * RLock
This commit is contained in:
@@ -397,14 +397,14 @@ func (b *Buffer) Write(pkt []byte) (n int, err error) {
|
||||
packet: packet,
|
||||
arrivalTime: now,
|
||||
})
|
||||
b.Unlock()
|
||||
b.readCond.Broadcast()
|
||||
b.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
b.calc(pkt, &rtpPacket, now, false)
|
||||
b.Unlock()
|
||||
b.readCond.Broadcast()
|
||||
b.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -507,6 +507,7 @@ func (b *Buffer) Close() error {
|
||||
|
||||
b.RLock()
|
||||
rtpStats := b.rtpStats
|
||||
b.readCond.Broadcast()
|
||||
b.RUnlock()
|
||||
|
||||
if rtpStats != nil {
|
||||
@@ -520,7 +521,6 @@ func (b *Buffer) Close() error {
|
||||
}
|
||||
}
|
||||
|
||||
b.readCond.Broadcast()
|
||||
if cb := b.getOnClose(); cb != nil {
|
||||
cb()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user