fix: use mutex-protected config copy in onReload — prevents stale reads

This commit is contained in:
Claus Lohmar 2026-08-06 19:07:08 +01:00
parent 700a0ab4f0
commit c85bba8d56

View file

@ -83,8 +83,13 @@ func main() {
if app.go2rtc != nil { app.go2rtc.Stop() }
if app.snapshots != nil { app.snapshots.StopAll() }
if app.recorder != nil { app.recorder.StopAll() }
// Read config under lock to get latest state.
app.server.mu.RLock()
liveCfg := *app.server.appConfig // copy, not pointer
app.server.mu.RUnlock()
// Handle viewer server toggle.
liveCfg := app.server.appConfig
if liveCfg.Auth.Viewer.Enabled && app.viewerSrv == nil {
go func() {
v, err := app.server.StartViewerServer()