Fixed unclean DownTrack close when removed before bound. (#736)

* Fixed unclean DownTrack close when removed before bound.

When a DownTrack is closed before it had a chance to be bound to a
transceiver, we'd skip close and leave it hanging. This is unlikely in
normal operations. However, it can be seen with permissions and
subscription APIs.

* remove remaining peerID references
This commit is contained in:
David Zhao
2022-05-29 22:09:02 -07:00
committed by GitHub
parent 3a45f93fdd
commit 7ad51f49f1
8 changed files with 120 additions and 98 deletions
+5 -5
View File
@@ -61,23 +61,23 @@ func (d *DownTrackSpreader) Store(ts TrackSender) {
d.downTrackMu.Lock()
defer d.downTrackMu.Unlock()
d.downTracks[ts.PeerID()] = ts
d.downTracks[ts.SubscriberID()] = ts
d.shadowDownTracks()
}
func (d *DownTrackSpreader) Free(peerID livekit.ParticipantID) {
func (d *DownTrackSpreader) Free(subscriberID livekit.ParticipantID) {
d.downTrackMu.Lock()
defer d.downTrackMu.Unlock()
delete(d.downTracks, peerID)
delete(d.downTracks, subscriberID)
d.shadowDownTracks()
}
func (d *DownTrackSpreader) HasDownTrack(peerID livekit.ParticipantID) bool {
func (d *DownTrackSpreader) HasDownTrack(subscriberID livekit.ParticipantID) bool {
d.downTrackMu.RLock()
defer d.downTrackMu.RUnlock()
_, ok := d.downTracks[peerID]
_, ok := d.downTracks[subscriberID]
return ok
}