AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
5.01k stars 399 forks source link

Crash when creating new streams #1394

Open franconoronha opened 2 weeks ago

franconoronha commented 2 weeks ago

My server has been crashing when I try to create multiple streams through the API. Wondering if it's fixable or if I should I just space them out. Logs:

fatal error: concurrent map writes
fatal error: concurrent map writes
fatal error: concurrent map writes
goroutine 35 [running]:
github.com/AlexxIT/go2rtc/internal/streams.New({0xc000704016, 0x3}, {0xc000618150, 0x68})
        github.com/AlexxIT/go2rtc/internal/streams/streams.go:65 +0x7d
github.com/AlexxIT/go2rtc/internal/streams.apiStreams({0xc48df0, 0xc00061a0e0}, 0xc00029e480)
        github.com/AlexxIT/go2rtc/internal/streams/api.go:51 +0x2d9
net/http.HandlerFunc.ServeHTTP(0x112b060?, {0xc48df0?, 0xc00061a0e0?}, 0xb333c4?)
        net/http/server.go:2166 +0x29
net/http.(*ServeMux).ServeHTTP(0xc00060c120?, {0xc48df0, 0xc00061a0e0}, 0xc00029e480)
        net/http/server.go:2683 +0x1ad
github.com/AlexxIT/go2rtc/internal/api.Init.middlewareCORS.func1({0xc48df0, 0xc00061a0e0}, 0xc00029e480)
        github.com/AlexxIT/go2rtc/internal/api/api.go:220 +0xd5
net/http.HandlerFunc.ServeHTTP(0x309339?, {0xc48df0?, 0xc00061a0e0?}, 0xc0001d9b68?)
        net/http/server.go:2166 +0x29
net/http.serverHandler.ServeHTTP({0xc00028c3c0?}, {0xc48df0?, 0xc00061a0e0?}, 0x6?)
        net/http/server.go:3137 +0x8e
net/http.(*conn).serve(0xc000232090, {0xc4a440, 0xc000200270})
        net/http/server.go:2039 +0x5e8
created by net/http.(*Server).Serve in goroutine 6
        net/http/server.go:3285 +0x4b4
AlexxIT commented 2 weeks ago

I think this is already fixed in master version https://github.com/AlexxIT/go2rtc/pull/1355

franconoronha commented 2 weeks ago

Should have checked better if It was pointed out already, sorry. Ty!