fix: lock map before read

This commit is contained in:
langhuihui
2023-12-14 13:26:34 +08:00
parent d0d43f80c4
commit 6e5ce878ed

View File

@@ -33,12 +33,15 @@ func (p *PreviewConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s += "<h2>pull stream on subscribe 订阅时才会触发拉流的流</h2>"
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("<h3>%s</h3>", name)
for streamPath, url := range pullonsub {
for streamPath, url := range pullconf.PullOnSub {
s += fmt.Sprintf("<a href='%s'>%s</a> <-- %s<br>", streamPath, streamPath, url)
}
}
pullconf.PullOnSubLocker.RUnlock()
}
}
w.Write([]byte(s))