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,
|
packet: packet,
|
||||||
arrivalTime: now,
|
arrivalTime: now,
|
||||||
})
|
})
|
||||||
b.Unlock()
|
|
||||||
b.readCond.Broadcast()
|
b.readCond.Broadcast()
|
||||||
|
b.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
b.calc(pkt, &rtpPacket, now, false)
|
b.calc(pkt, &rtpPacket, now, false)
|
||||||
b.Unlock()
|
|
||||||
b.readCond.Broadcast()
|
b.readCond.Broadcast()
|
||||||
|
b.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,6 +507,7 @@ func (b *Buffer) Close() error {
|
|||||||
|
|
||||||
b.RLock()
|
b.RLock()
|
||||||
rtpStats := b.rtpStats
|
rtpStats := b.rtpStats
|
||||||
|
b.readCond.Broadcast()
|
||||||
b.RUnlock()
|
b.RUnlock()
|
||||||
|
|
||||||
if rtpStats != nil {
|
if rtpStats != nil {
|
||||||
@@ -520,7 +521,6 @@ func (b *Buffer) Close() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b.readCond.Broadcast()
|
|
||||||
if cb := b.getOnClose(); cb != nil {
|
if cb := b.getOnClose(); cb != nil {
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user