修复:weblive 协程 panic 防护、Mongo 空指针防护、直播状态轮询退避

Made-with: Cursor
This commit is contained in:
whm
2026-03-25 16:45:22 +08:00
parent 70e6782713
commit 7e24a965bc
6 changed files with 70 additions and 12 deletions

View File

@@ -154,7 +154,7 @@ func (h *Hub) onPublisherTrack(track *webrtc.TrackRemote) {
h.mu.Lock()
h.forwarders = append(h.forwarders, tf)
h.mu.Unlock()
go tf.runReadLoop()
goSafe("trackRead", tf.runReadLoop)
// 观众仅在「已开播」后拉流:首次协商时 attachForwardersToViewerPC 会带上当前全部轨,无需在此重协商
}
@@ -173,14 +173,14 @@ func (h *Hub) attachForwardersToViewerPC(v *viewerSession) {
continue
}
// Drain RTCP feedback to keep interceptors/senders healthy.
go func() {
goSafe("viewerRTCP", func() {
rtcpBuf := make([]byte, 1500)
for {
if _, _, e := rtpSender.Read(rtcpBuf); e != nil {
return
}
}
}()
})
tf.addViewer(v.id, lt)
}
}