Browse Source

api: fix crash when calling /v1/webrtcsessions/list just after session creation (#2097)

pull/2098/head
Alessandro Ros 2 years ago committed by GitHub
parent
commit
af23609d47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      internal/core/webrtc_manager.go
  2. 11
      internal/core/webrtc_session.go

2
internal/core/webrtc_manager.go

@ -269,7 +269,7 @@ outer: @@ -269,7 +269,7 @@ outer:
sx := newWebRTCSession(
m.ctx,
m.readBufferCount,
req.remoteAddr,
req,
&wg,
m.iceHostNAT1To1IPs,
m.iceUDPMux,

11
internal/core/webrtc_session.go

@ -113,6 +113,7 @@ type webRTCSessionPathManager interface { @@ -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 { @@ -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 { @@ -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( @@ -149,6 +149,7 @@ func newWebRTCSession(
s := &webRTCSession{
readBufferCount: readBufferCount,
req: req,
wg: wg,
iceHostNAT1To1IPs: iceHostNAT1To1IPs,
iceUDPMux: iceUDPMux,
@ -164,7 +165,7 @@ func newWebRTCSession( @@ -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() { @@ -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…
Cancel
Save