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 interceptor after PeerConnection is closed #2977

Merged
merged 1 commit into from
Dec 24, 2024
Merged
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 interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ func Test_Interceptor_BindUnbind(t *testing.T) {
}
}()

closePairNow(t, sender, receiver)
assert.NoError(t, sender.GracefulClose())
assert.NoError(t, receiver.GracefulClose())

// Bind/UnbindLocal/RemoteStream should be called from one side.
if cnt := atomic.LoadUint32(&cntBindLocalStream); cnt != 1 {
Expand Down
5 changes: 3 additions & 2 deletions peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2209,8 +2209,6 @@ func (pc *PeerConnection) close(shouldGracefullyClose bool) error {
// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #3)
pc.signalingState.Set(SignalingStateClosed)

closeErrs = append(closeErrs, pc.api.interceptor.Close())

// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #4)
pc.mu.Lock()
for _, t := range pc.rtpTransceivers {
Expand Down Expand Up @@ -2247,6 +2245,9 @@ func (pc *PeerConnection) close(shouldGracefullyClose bool) error {

closeErrs = append(closeErrs, doGracefulCloseOps()...)

// Interceptor closes at the end to prevent Bind from being called after interceptor is closed
closeErrs = append(closeErrs, pc.api.interceptor.Close())

return util.FlattenErrs(closeErrs)
}

Expand Down
Loading