Skip to content

Commit

Permalink
add test reproduce goroutine leaks on datachannel mux
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan Totting committed Apr 8, 2024
1 parent 371515b commit dc90fcf
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions datachannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

"github.com/pion/ice/v3"
"github.com/pion/transport/v3/test"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -360,6 +361,17 @@ func TestDataChannel_Close(t *testing.T) {
assert.NoError(t, dc.Close())
closePairNow(t, offerPC, answerPC)
})

t.Run("Close after PeerConnection With Mux Closed", func(t *testing.T) {
offerPC, answerPC, err := newPairWithMux()
assert.NoError(t, err)

dc, err := offerPC.CreateDataChannel(expectedLabel, nil)
assert.NoError(t, err)

closePairNow(t, offerPC, answerPC)
assert.NoError(t, dc.Close())
})
}

func TestDataChannelParameters(t *testing.T) {
Expand Down Expand Up @@ -518,3 +530,30 @@ func TestDataChannelParameters(t *testing.T) {
closeReliabilityParamTest(t, offerPC, answerPC, done)
})
}

func newPairWithMux() (*PeerConnection, *PeerConnection, error) {
settingEngine := SettingEngine{}

// Configure our SettingEngine to use our UDPMux. By default a PeerConnection has
// no global state. The API+SettingEngine allows the user to share state between them.
// In this case we are sharing our listening port across many.
// Listen on UDP Port 8443, will be used for all WebRTC traffic
mux, err := ice.NewMultiUDPMuxFromPort(8443)
if err != nil {
panic(err)
}

settingEngine.SetICEUDPMux(mux)
api := NewAPI(WithSettingEngine(settingEngine))
pca, err := api.NewPeerConnection(Configuration{})
if err != nil {
return nil, nil, err
}

pcb, err := NewPeerConnection(Configuration{})
if err != nil {
return nil, nil, err
}

return pca, pcb, nil
}

0 comments on commit dc90fcf

Please sign in to comment.