Skip to content

Commit

Permalink
webrtc: fix rcmgr OpenConnection call claiming that it uses a fd
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jun 13, 2023
1 parent affee88 commit 2aa6e81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions p2p/test/transport/rcmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

gomock "github.com/golang/mock/gomock"
"github.com/golang/mock/gomock"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
mocknetwork "github.com/libp2p/go-libp2p/core/network/mocks"
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestResourceManagerIsUsed(t *testing.T) {
}

expectFd := true
if strings.Contains(tc.Name, "QUIC") || strings.Contains(tc.Name, "WebTransport") {
if strings.Contains(tc.Name, "QUIC") || strings.Contains(tc.Name, "WebTransport") || strings.Contains(tc.Name, "WebRTC") {
expectFd = false
}

Expand Down Expand Up @@ -86,7 +86,7 @@ func TestResourceManagerIsUsed(t *testing.T) {
}
return nil
})
connScope.EXPECT().Done()
connScope.EXPECT().Done().MinTimes(1)

var allStreamsDone sync.WaitGroup

Expand Down
5 changes: 2 additions & 3 deletions p2p/transport/webrtc/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,11 @@ func (t *WebRTCTransport) listenSocket(socket *net.UDPConn) (tpt.Listener, error
}

func (t *WebRTCTransport) Dial(ctx context.Context, remoteMultiaddr ma.Multiaddr, p peer.ID) (tpt.CapableConn, error) {
scope, err := t.rcmgr.OpenConnection(network.DirOutbound, true, remoteMultiaddr)
scope, err := t.rcmgr.OpenConnection(network.DirOutbound, false, remoteMultiaddr)
if err != nil {
return nil, err
}
err = scope.SetPeer(p)
if err != nil {
if err := scope.SetPeer(p); err != nil {
scope.Done()
return nil, err
}
Expand Down

0 comments on commit 2aa6e81

Please sign in to comment.