From 6e5ce878edd055575a0f699d735b49fc62ab642c Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Thu, 14 Dec 2023 13:26:34 +0800 Subject: [PATCH] fix: lock map before read --- main.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 6086fe4..e481841 100644 --- a/main.go +++ b/main.go @@ -30,15 +30,18 @@ func (p *PreviewConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) { Streams.Range(func(streamPath string, stream *Stream) { s += fmt.Sprintf("%s [ %s ]
", streamPath, streamPath, stream.GetType()) }) - s+= "

pull stream on subscribe 订阅时才会触发拉流的流

" + s += "

pull stream on subscribe 订阅时才会触发拉流的流

" for name, p := range Plugins { if pullcfg, ok := p.Config.(config.PullConfig); ok { - if pullonsub := pullcfg.GetPullConfig().PullOnSub; pullonsub != nil { + pullconf := pullcfg.GetPullConfig() + pullconf.PullOnSubLocker.RLock() + if pullconf.PullOnSub != nil { s += fmt.Sprintf("

%s

", name) - for streamPath, url := range pullonsub { + for streamPath, url := range pullconf.PullOnSub { s += fmt.Sprintf("%s <-- %s
", streamPath, streamPath, url) } } + pullconf.PullOnSubLocker.RUnlock() } } w.Write([]byte(s))