From c85bba8d56e6b470db07ad790df3e97bd6d0577a Mon Sep 17 00:00:00 2001 From: cclohmar Date: Thu, 6 Aug 2026 19:07:08 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20use=20mutex-protected=20config=20copy=20?= =?UTF-8?q?in=20onReload=20=E2=80=94=20prevents=20stale=20reads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 9a3e0ad..e649b8e 100644 --- a/main.go +++ b/main.go @@ -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()