fix: use mutex-protected config copy in onReload — prevents stale reads
This commit is contained in:
parent
700a0ab4f0
commit
c85bba8d56
1 changed files with 6 additions and 1 deletions
7
main.go
7
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue