RTSPtoWeb
RTSPtoWeb copied to clipboard
fix: race condition on webrtc handler
Related to #497
Problem
My product is React WebAPP for GIS system, I use RTSPtoWeb as Media Server. My product's users sometimes create & close webrtc players in very short time. When there are many traffics, I found some of cameras does not release its RTSP Connection with RTSPtoWeb server. I fixed it and worked well in my product.
gin.Context Is Not Concurrency-Safe
gin.Context is not created each requests. Gin uses sync.Pool. so if there are many traffics, sometimes race condition happens. you should use Copy method or just store params on new variables.
cCopy := c.Copy()
go func() {
client add & client delete
}()
or
uuid := c.Param("uuid")
channel := c.Param("uuid")
go func() {
client add & client delete
}()