ion-sfu
ion-sfu copied to clipboard
Remain deleted stream's RTCPReader in BufferFactory
Your environment.
- Version: Latest (Master)
- Client: Chrome(pubsub test)
- Environement: OSX
- Are you using a TURN server? No
What did you expect?
- Don't remain RTCPReader in buffer.Factory
What happened?
https://github.com/pion/ion-sfu/blob/d7b670b037fb01d4860686023a757d36cf434357/pkg/buffer/factory.go#L49
func (f *Factory) GetOrNew(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser {
f.Lock()
defer f.Unlock()
switch packetType {
case packetio.RTCPBufferPacket:
if reader, ok := f.rtcpReaders[ssrc]; ok {
return reader
}
reader := NewRTCPReader(ssrc)
f.rtcpReaders[ssrc] = reader
reader.OnClose(func() {
f.Lock()
delete(f.rtcpReaders, ssrc)
f.Unlock()
})
return reader
case packetio.RTPBufferPacket:
if reader, ok := f.rtpBuffers[ssrc]; ok {
return reader
}
buffer := NewBuffer(ssrc, f.videoPool, f.audioPool, f.logger)
f.rtpBuffers[ssrc] = buffer
buffer.OnClose(func() {
f.Lock()
delete(f.rtpBuffers, ssrc)
f.Unlock()
})
return buffer
}
return nil
}
When RTCPReader is closed, it is also deleted from rtcpReaders
immediately.
But some message's are coming via rtcp session after it.
And then new message call GetOrNew() and make RTCPReader and store in rtcpReaders
.
Finally unmanaged RTCPReader is stored in rtcpReaders
.
So I think add some waiting time for flushing message from closed rtcp session.
Hey @Rollooo, good catch let me see how we can fix this, I think we can wait on a BYE packet or timeout.