Skip to content

Commit

Permalink
fix negotiation blocked when channel closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan Totting committed Apr 7, 2024
1 parent dbe4bbb commit 3aaa2f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client.go
Expand Up @@ -624,7 +624,12 @@ func (c *Client) Negotiate(offer webrtc.SessionDescription) (*webrtc.SessionDesc
ErrorChan: errorChan,
})

localCtx, cancel := context.WithCancel(c.context)
defer cancel()

select {
case <-localCtx.Done():
return nil, ErrClientStoped
case err := <-errorChan:
return nil, err
case answer := <-answerChan:
Expand Down
4 changes: 4 additions & 0 deletions queue.go
Expand Up @@ -57,6 +57,10 @@ func (q *queue) Push(item interface{}) {

if !q.IsOpen.Load() {
glog.Warning("sfu: queue is closed when push renegotiation")
if opItem, ok := item.(negotiationQueue); ok {
opItem.ErrorChan <- ErrQueueIsClosed
}

return
}

Expand Down

0 comments on commit 3aaa2f8

Please sign in to comment.