Add checks for participant and sub-components close. (#4100)
* Add checks for participant and sub-components close. Looks like there might be some memory leak with participant sessions not getting closed properly. Adding checks (to be cleaned up later) to see if there is a consistent place where things might hang. * init with right type * Remove unnecessary goroutine, thank you @milos-lk * clean up
This commit is contained in:
@@ -104,7 +104,21 @@ func (m *SubscriptionManager) Close(isExpectedToResume bool) {
|
||||
close(m.closeCh)
|
||||
m.lock.Unlock()
|
||||
|
||||
var done atomic.Bool
|
||||
var downTracksClosed atomic.Bool
|
||||
time.AfterFunc(time.Minute, func() { // CLOSE-DEBUG-CLEANUP
|
||||
if !done.Load() || !downTracksClosed.Load() {
|
||||
m.params.Logger.Infow(
|
||||
"subscription maanager close timeout",
|
||||
"done", done.Load(),
|
||||
"downTracksClosed", downTracksClosed.Load(),
|
||||
"numSubscribedTracks", len(m.GetSubscribedTracks()),
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
<-m.doneCh
|
||||
done.Store(true)
|
||||
|
||||
subTracks := m.GetSubscribedTracks()
|
||||
downTracksToClose := make([]*sfu.DownTrack, 0, len(subTracks))
|
||||
@@ -127,6 +141,7 @@ func (m *SubscriptionManager) Close(isExpectedToResume bool) {
|
||||
go dt.CloseWithFlush(true)
|
||||
}
|
||||
}
|
||||
downTracksClosed.Store(true)
|
||||
}
|
||||
|
||||
func (m *SubscriptionManager) isClosed() bool {
|
||||
|
||||
Reference in New Issue
Block a user