Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close peerconnection ice gatherer on close #2658

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion icegatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package webrtc

import (
"errors"
"fmt"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -192,7 +193,7 @@ func (g *ICEGatherer) Close() error {

if g.agent == nil {
return nil
} else if err := g.agent.Close(); err != nil {
} else if err := g.agent.Close(); err != nil && !errors.Is(err, ice.ErrClosed) {
return err
}

Expand Down
9 changes: 7 additions & 2 deletions icetransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package webrtc

import (
"context"
"errors"
"fmt"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -197,9 +198,13 @@ func (t *ICETransport) Stop() error {
}

if t.mux != nil {
return t.mux.Close()
if err := t.mux.Close(); err != nil && !errors.Is(err, ice.ErrClosed) {
return err
}
} else if t.gatherer != nil {
return t.gatherer.Close()
if err := t.gatherer.Close(); err != nil && !errors.Is(err, ice.ErrClosed) {
return err
}
}
return nil
}
Expand Down
7 changes: 6 additions & 1 deletion peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,12 @@ func (pc *PeerConnection) Close() error {
// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #7)
closeErrs = append(closeErrs, pc.dtlsTransport.Stop())

// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #8, #9, #10)
// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #8)
if pc.iceGatherer != nil {
closeErrs = append(closeErrs, pc.iceGatherer.Close())
}
Comment on lines +2087 to +2089
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iceTransport closes it's own gatherer, but the peerconnection also maintains it's own separate iceGatherer. Should close this one too.


// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #9, #10)
if pc.iceTransport != nil {
closeErrs = append(closeErrs, pc.iceTransport.Stop())
}
Expand Down
Loading