mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-10 00:39:28 +00:00
api: fix crash when calling /v1/webrtcsessions/list just after session creation (#2097)
This commit is contained in:
parent
3bb12e2a0a
commit
af23609d47
@ -269,7 +269,7 @@ outer:
|
||||
sx := newWebRTCSession(
|
||||
m.ctx,
|
||||
m.readBufferCount,
|
||||
req.remoteAddr,
|
||||
req,
|
||||
&wg,
|
||||
m.iceHostNAT1To1IPs,
|
||||
m.iceUDPMux,
|
||||
|
@ -113,6 +113,7 @@ type webRTCSessionPathManager interface {
|
||||
|
||||
type webRTCSession struct {
|
||||
readBufferCount int
|
||||
req webRTCSessionNewReq
|
||||
wg *sync.WaitGroup
|
||||
iceHostNAT1To1IPs []string
|
||||
iceUDPMux ice.UDPMux
|
||||
@ -125,7 +126,6 @@ type webRTCSession struct {
|
||||
created time.Time
|
||||
uuid uuid.UUID
|
||||
secret uuid.UUID
|
||||
req webRTCSessionNewReq
|
||||
answerSent bool
|
||||
mutex sync.RWMutex
|
||||
pc *peerConnection
|
||||
@ -137,7 +137,7 @@ type webRTCSession struct {
|
||||
func newWebRTCSession(
|
||||
parentCtx context.Context,
|
||||
readBufferCount int,
|
||||
remoteAddr string,
|
||||
req webRTCSessionNewReq,
|
||||
wg *sync.WaitGroup,
|
||||
iceHostNAT1To1IPs []string,
|
||||
iceUDPMux ice.UDPMux,
|
||||
@ -149,6 +149,7 @@ func newWebRTCSession(
|
||||
|
||||
s := &webRTCSession{
|
||||
readBufferCount: readBufferCount,
|
||||
req: req,
|
||||
wg: wg,
|
||||
iceHostNAT1To1IPs: iceHostNAT1To1IPs,
|
||||
iceUDPMux: iceUDPMux,
|
||||
@ -164,7 +165,7 @@ func newWebRTCSession(
|
||||
chAddCandidates: make(chan webRTCSessionAddCandidatesReq),
|
||||
}
|
||||
|
||||
s.Log(logger.Info, "created by %s", remoteAddr)
|
||||
s.Log(logger.Info, "created by %s", req.remoteAddr)
|
||||
|
||||
wg.Add(1)
|
||||
go s.run()
|
||||
@ -195,8 +196,8 @@ func (s *webRTCSession) run() {
|
||||
|
||||
func (s *webRTCSession) runInner() error {
|
||||
select {
|
||||
case req := <-s.chNew:
|
||||
s.req = req
|
||||
case <-s.chNew:
|
||||
// do not store the request, we already have it
|
||||
|
||||
case <-s.ctx.Done():
|
||||
return fmt.Errorf("terminated")
|
||||
|
Loading…
Reference in New Issue
Block a user