restreamer
restreamer copied to clipboard
Panic due to double channel close in Streamer.Stream()
In Streamer.Stream(), there is an inherent concurrency issue, because the Connection.Closed flag is used to determine if the Connection.Queue channel needs to be closed or not: https://github.com/onitake/restreamer/blob/6a701cadf949030788c0d29b3952ac40da487053/streaming/streamer.go#L334-L336
If someone closes the channel, the flag update is delayed, and a concurrent goroutine may try to close it again: https://github.com/onitake/restreamer/blob/6a701cadf949030788c0d29b3952ac40da487053/streaming/connection.go#L132
As quick&dirty workaround, recover() can be used, but it would be better to remove this flag and find a different way to signal closure and trigger cleanup.